Community
    • Login

    Horizontal line question

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    38 Posts 6 Posters 11.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Snabel42S
      Snabel42 @PeterJones
      last edited by

      @peterjones I work with a lot system files with a flat structyre, they all have various fixed lengths.
      The output however is often transmitted/stored in a single line, or lines that does not match how the system consumes/processes the data.

      Being able to visually line up the data at fixed line lengths depending on context makes it possible to analyze.
      It doesn’t have much to do with preferring it one way or the other, but rather to be able to predict or problem solve the system processing.

      Most commonly I position to the front of the file and use a simple replace regular expression at whatever file length I need.
      Something like this for a line length of 80 characters

      268b5025-6895-48d0-8112-73d4dae9264e-image.png

      1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Snabel42
        last edited by PeterJones

        @snabel42 said in Horizontal line question:

        This would be a feature request then, a UI or keyboard command to split lines on the fly while also being able to specify the line break character position.

        Defining where splits happen is the raison d’être of the Settings > Preferences > Margins/Border/Edge > Vertical Edge Settings box. Literally. It’s the first and primary reason that setting exists. The visible marker is there to help you see where that wrap occurs. But if the reason you don’t want to use that setting is because you don’t like seeing the line, all you have to do is go to Settings > Style Configurator, select Language: Global Styles and Style: Edge colour, and change the foreground color from the current value (cyan on mine) to a color that blends in with your background color (white on mine). Then you won’t see the line, but it will still allow Ctrl+I to wrap there.

        If you wanted to make a feature request, we have a FAQ explaining where to do that. My guess is that such a “live re-paragraphing” feature wouldn’t be something the developers would be interested in implementing, but I have been known to guess wrongly as to what they will implement.

        But as a feature that I would think would be more likely to be implemented, and more generally-useful IMO, would be to have a checkbox on the Vertical Edge Settings section which says “☐ Apply rightmost vertical edge as the Word Wrap margin”, so that the built-in word-wrap feature would make use of the vertical edge setting in deciding where the wrap should occur.

        Note: the above was written before your followon post, to which I respond below

        ----

        I work with a lot system files with a flat structyre, they all have various fixed lengths.

        Ah. So if I interpret that new information correctly, you don’t really need “live” reformatting, you really are more looking for a one-time-per-file thing that does it? If you have just a few different lengths (maybe 80, 120, and 129), then it would probably be easiest to do a few different search-and-replace macro recordings where you apply the appropriate regex in each). If you need more arbitrary than that, then a PythonScript solution would work, which could be run on-demand for the active file. (It would only be a one-directional script: it would only add the newlines, not remove them). I have an idea for how it would be implmented --when you run the script, it would prompt you for the number of characters; then it would create the right regex based on those characters, and run the regex on the active file – so if you say that manually running this once per file would meet your needs, I can code it up for you and share it sometime in the next hour or two.

        PeterJonesP Snabel42S 2 Replies Last reply Reply Quote 2
        • PeterJonesP
          PeterJones @PeterJones
          last edited by

          @peterjones said in Horizontal line question:

          I can code it up for you and share it sometime

          With that simple requirement of inputting the width and running a regex based on that width, it only took three lines of active PythonScript code (and some boilerplate/comments):

          # encoding=utf-8
          """in response to https://community.notepad-plus-plus.org/topic/23171/horizontal-line-question/29
          
          This will prompt for a number, and then run a regex to hardwrap after that column
          """
          from Npp import editor,notepad,console
          
          colstr = notepad.prompt("Column", "Hard Wrap at Column", 80) # defaults to 80 characters, but you can just type over the value in the prompt box
          srch = r'^.{' + colstr + '}'
          editor.rereplace(srch, r'$0\r\n')
          

          For installation/usage instructions, see the FAQ

          1 Reply Last reply Reply Quote 2
          • PeterJonesP PeterJones referenced this topic on
          • Snabel42S
            Snabel42 @PeterJones
            last edited by

            @peterjones said in Horizontal line question:

            Ah. So if I interpret that new information correctly, you don’t really need “live” reformatting, you really are more looking for a one-time-per-file thing that does it? If you have just a few different lengths (maybe 80, 120, and 129), then it would probably be easiest to do a few different search-and-replace macro recordings where you apply the appropriate regex in each).

            I think you nailed it. Each file opened would only ever have a one-time-reformatting need to whatever the appropriate line length happens to be.

            I usually can’t know the appropriate length until I actually open the file, but there’s only really so many lengths that are actually used per system/context. Likely building a small library of macro recording would like solve my needs.
            I haven’t worked with macros in notepad++ yet, but this seems like a good excuse to start.

            (I didn’t even think of this as a feature until I saw it done by a colleague in UltraEdit)

            PeterJonesP 2 Replies Last reply Reply Quote 2
            • PeterJonesP
              PeterJones @Snabel42
              last edited by

              @snabel42 ,

              The script I shared will work for your needs. But if you want to learn how to record and save the macros, then this is a great exercise for it.

              Snabel42S 1 Reply Last reply Reply Quote 0
              • Snabel42S
                Snabel42 @PeterJones
                last edited by

                @peterjones said in Horizontal line question:

                @snabel42 ,

                The script I shared will work for your needs. But if you want to learn how to record and save the macros, then this is a great exercise for it.

                Both methods break new ground for me personally, so I’ll try both for the general experience.

                Thanks!

                1 Reply Last reply Reply Quote 1
                • PeterJonesP
                  PeterJones @Snabel42
                  last edited by

                  @snabel42 , @JillPlaysMC

                  BTW: sorry for confusing you two earlier: I didn’t realize that when @Snabel42 jumped in, it was a different user – I wasn’t looking at the user names, and assumed that it was a follow on by the original poster (hence my comment about resuming “your” conversation with @Ekopalypse). My bad.

                  Snabel42S 1 Reply Last reply Reply Quote 1
                  • Snabel42S
                    Snabel42 @PeterJones
                    last edited by

                    @peterjones probably bad form by me semi-hijacking the thread…

                    PeterJonesP 1 Reply Last reply Reply Quote 0
                    • PeterJonesP
                      PeterJones @Snabel42
                      last edited by PeterJones

                      @snabel42 said in Horizontal line question:

                      probably bad form by me semi-hijacking the thread…

                      Not at all. This is a conversational forum, so the conversation can move or evolve, and different people can get involved. I just didn’t notice the change in user.

                      It just means that, while a one-time script or macro will work for you, we still don’t know whether @JillPlaysMC needs “live” or whether one-time would work for them as well.

                      Snabel42S 1 Reply Last reply Reply Quote 0
                      • Snabel42S
                        Snabel42 @PeterJones
                        last edited by

                        @peterjones if it’s interesting, I finally hunted down the relevant UltraEdit wiki page as well as a screenshot of it being used

                        53912d41-6bdc-41b2-8ef1-f32e5a520a63-image.png

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors