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.
    • Neil SchipperN
      Neil Schipper @JillPlaysMC
      last edited by

      @jillplaysmc
      So you’ve executed 2 out of 4 steps, but you don’t want to continue with the instructions to see if it meets your need?

      You also haven’t stated whether you want to control the appearance “for now” vs. change the file so it persistently has the shorter lines.

      1 Reply Last reply Reply Quote 0
      • Neil SchipperN
        Neil Schipper @Ekopalypse
        last edited by

        @ekopalypse said in Horizontal line question:

        but this does not do it automatically when you edit text

        Right. Maybe Jill will clarify that aspect of what she wants.

        1 Reply Last reply Reply Quote 1
        • JillPlaysMCJ
          JillPlaysMC @Neil Schipper
          last edited by

          @neil-schipper As for steps 3 and 4, what do you mean by select some or all lines, and what does split lines do?

          Neil SchipperN 1 Reply Last reply Reply Quote 0
          • Neil SchipperN
            Neil Schipper @JillPlaysMC
            last edited by

            @jillplaysmc
            Selecting is when you hold down Shift and cursor around or click-and-drag around. Selected text gets differently colored, and can then be copied (Ctrl-c) or cut (Ctrl-x) or undergo other operations.

            So, select a bunch of lines, issue Ctrl-i and see if you are happy with the result.

            Play around a lot. As you try different things you can issue undo (ctrl-z) commands to get back to where you were.

            JillPlaysMCJ 1 Reply Last reply Reply Quote 0
            • JillPlaysMCJ
              JillPlaysMC @Neil Schipper
              last edited by

              @neil-schipper When I try Ctrl + I nothing happens

              Neil SchipperN 1 Reply Last reply Reply Quote 0
              • Neil SchipperN
                Neil Schipper @JillPlaysMC
                last edited by

                @jillplaysmc

                Here’s a “before” shot. Notice that lines 6 to 10 are selected:

                2ab74e0f-803b-4bfa-bfaa-936212c1a2af-image.png

                Here’s what we get after Ctrl + i and then widening the window. Notice that the old line 6 is now 2 lines 6 & 7, and, old line 9 is now 3 lines 10, 11 & 12.

                ef9643d5-438c-4ab5-b39e-4bf0e21a1417-image.png

                Neil SchipperN PeterJonesP 2 Replies Last reply Reply Quote 0
                • Neil SchipperN
                  Neil Schipper @Neil Schipper
                  last edited by

                  @neil-schipper said in Horizontal line question:

                  and, old line 9 is now 3 lines 10, 11 & 12.

                  … and please notice that the widening did not effect the wrap point of lines 6 - 12.

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

                    @neil-schipper & @JillPlaysMC ,

                    You can also set Settings > Preferences > Margins/Borders/Edge > Vertical Edge Settings = 129, which will draw a colored line at character 129, and when you do the Ctrl+I to split the lines, it will split the selected text at that exact location instead of however wide the window happens to be.

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

                      @peterjones how would you ‘split’ at a certain character position without using this setting?

                      I normally do a regular expression for it, but maybe there’s a quicker/simpler way with the split command?

                      Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 0
                      • Alan KilbornA
                        Alan Kilborn @Snabel42
                        last edited by Alan Kilborn

                        @snabel42 said in Horizontal line question:

                        how would you ‘split’ at a certain character position without using this setting?

                        You can’t (well, you can do it with regex but you already know this); it’s all in the USER MANUAL.

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

                          @alan-kilborn thanks! Thought that was the case, but figured I’d ask once if I was missing something.

                          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.

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

                            @snabel42 ,

                            how would you ‘split’ at a certain character position without using this setting?

                            To do a “split”, you either use this setting, or use the complicated process of adjusting the screen width that Neil already described, or do the regex that you claim to know how to do.

                            Notepad++ is a text editor, not a word processor. It’s not going to automatically re-flow the text as you type like MS Word does and automatically delete and insert actual newline characters because you don’t like the word-wrap as-is.
                            To do that, you would need to use a word processor, or maybe someone could tell you of a plugin for Notepad++ that does that (but I know of no such plugin). The PythonScript solution would be writing a script which tries to do it “on the fly” as you edit, but would require a custom script, and lots of back-and-forth to develop; beyond that, it won’t be very efficient, so if you’re doing a big file, you might find such a “live script” annoyingly slow. (Unfortunately, you seem to have abandoned going down that road with Ekopalypse; if you really want it on-the-fly, I’d suggest focusing on that, rather than getting distracted).

                            My suggestions for you: do one of the two following options:

                            1. Do it all in native Notepad++, not on the fly.
                              • Turn on word wrap
                              • adjust the window width or not, depending on whether you want it closer to the end goal or not
                              • type all your paragraphs, not worrying about the in-paragraph newlines, and put two newlines between paragraphs
                              • once done, set the setting to 129 characters, then use Ctrl+A to select all your text, then use Ctrl+I to split the paragraphs into individual lines. Clear that setting when you’re done, if the vertical line bothers you.
                            2. If you want it on the fly,
                              • stop with the diversion into the non-automatic with split
                              • return to your conversation with Ekopalypse, and hope that he continues to have interest in giving you a proof-of-concept script
                                • because, while I can do some PythonScript, I would think it would be really complicated to implement and have no implementation ideas
                                • if Ekopalypse has an idea, more power to you both
                            Snabel42S 1 Reply Last reply Reply Quote 0
                            • 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
                                            • First post
                                              Last post
                                            The Community of users of the Notepad++ text editor.
                                            Powered by NodeBB | Contributors