• Login
Community
  • Login

auto insert <br> at the end of every line

Scheduled Pinned Locked Moved General Discussion
10 Posts 8 Posters 2.7k 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.
  • D
    dralxnder
    last edited by Oct 3, 2023, 3:02 AM

    Hello all,

    I use notepad++ to write patient notes which I then copy and paste into my hospital’s electronic record. Due to ‘reasons’ I need to have <br> at the end of each line if I do not want my notes to be one amorphous blob.

    Is there a way to easily inset <br> at the end of every line without manually copy pasting it?

    Cheers,

    alx

    A 1 Reply Last reply Oct 3, 2023, 11:24 AM Reply Quote 0
    • C
      Coises
      last edited by Coises Oct 3, 2023, 4:08 AM Oct 3, 2023, 4:07 AM

      Select Replace… from the Search menu.

      Enter:

      Find what: $
      Replace with: <br>

      and be sure Regular expression is checked in the Search Mode box; then click Replace All.

      This will add a <br> after every line, even the last one, so you’ll probably want to delete the final <br>.

      1 Reply Last reply Reply Quote 4
      • A
        Alan Kilborn @dralxnder
        last edited by Alan Kilborn Oct 3, 2023, 11:27 AM Oct 3, 2023, 11:24 AM

        @dralxnder

        “Auto insertion” is a bit difficult to achieve; let’s assume that it is okay for you to type a bit of patient notes, using the Enter key to break lines as one would normally do. When you are somewhat happy with your notes, you run an extra operation to put the special line break sequences in, as @Coises mentioned.

        While @Coises 's solution works, manually setting it up and doing it over and over again can get tedious. It might be better to record such an operation as a macro (REF.), which you can then either run from the Macro menu when you need it, or bind it to a keycombo for even faster and less obtrusive access.

        Here’s how I might set it up (note: a bit different than @Coises), assuming that files have Windows line-endings (the typical case):

        626e1fa3-2990-4596-b4ae-2829bb6bf86d-image.png

        After this setup, press the Replace All button.

        1 Reply Last reply Reply Quote 5
        • P
          Peter Shaw
          last edited by Mar 20, 2024, 3:21 AM

          How about this for a way to do it:

          • Size the Notepad++ window to the width you want and turn on word wrap.
          • Record a Macro in which you “End” the cursor to the end of line (<End> key), delete one space, then press the <Enter> key, and then stop recording the macro.
          • You can save it with a suitable name if you want.
          • <CTRL-SHIFT P> runs the macro as many times as you want, or you could run it multiple times from the Menu.

          Works for me and it’s very easy to adjust how long you want each line to be!

          N 1 Reply Last reply Mar 20, 2024, 10:12 AM Reply Quote 1
          • N
            notdodgeball @Peter Shaw
            last edited by notdodgeball Mar 20, 2024, 10:18 AM Mar 20, 2024, 10:12 AM

            @Peter-Shaw
            I may be understanding it incorrectly, but I think the Split Lines command (Ctrl+I) would be a better way to achieve what you describe.

            M 1 Reply Last reply Mar 20, 2024, 9:25 PM Reply Quote 0
            • M
              mkupper @notdodgeball
              last edited by mkupper Mar 20, 2024, 9:26 PM Mar 20, 2024, 9:25 PM

              @notdodgeball I think @Peter-Shaw was showing a way that people can dynamically wrap text to an easily configurable width until it looks good. At that point Peter Shaw’s method splits the lines at the spots where Notepad’s wrap thing had wrapped.

              I thought Peter Shaw’s suggestion it was a nifty though not perfect idea. If you are already at the end of a line created by automatic wrapping then End takes you to the end of the physical line. I can’t think of a clean fix that allows for being anywhere on a line from the first to last position and then moving to the end of the line if, and only if, you are already at the end of the line. I suspect it can be done in Pythonscript though don’t know if within Pythonscript the code can discover details about the state of auto-wrapped lines.

              A better word wrapper is something I have some interest in.

              With TextFX a person could play with the wrap width by loading the desired width into the copy/paste buffer but it was still laborious. When TextFX still worked well I used this, particularly when writing comments in code. I’m indented at some level in the code and want to write a comment that wraps. I’d end up putting the comment on the left margin, loading a small number such as 40 into the copy/paste buffer, and seeing how that looked after wrapping via TextFx. At times I would fiddle with the wrap size to avoid a strange looking layout of the lines.

              Both TextFX’s and Notepad++'s wrappers have things I really like and things that bug me. For example, I want to be able re-wrap multiple paragraphs.

              FWIW - this sub-thread should be moved to it’s own topic as it’s not directly related to appending a <br> at the end of each line

              N 1 Reply Last reply Mar 21, 2024, 1:06 PM Reply Quote 0
              • N
                notdodgeball @mkupper
                last edited by Mar 21, 2024, 1:06 PM

                @mkupper, thanks, I understand. I used to micromanage my lines like that, it’s not worth it.

                When TextFX still worked well I used this, particularly when writing

                Just curious, now it doesn’t?

                J M 2 Replies Last reply Mar 21, 2024, 1:42 PM Reply Quote 1
                • J
                  Jim Dailey @notdodgeball
                  last edited by Mar 21, 2024, 1:42 PM

                  @notdodgeball I am using TextFX2 with NPP 8.6.4 32-bit. It seems to work like the older TextFX, AFAICT.

                  1 Reply Last reply Reply Quote 1
                  • M
                    mkupper @notdodgeball
                    last edited by Mar 21, 2024, 8:44 PM

                    @notdodgeball said in auto insert <br> at the end of every line:

                    Just curious, now it doesn’t?

                    I have forgotten why I never switched to TextFX2. I ended up not updating Notepad++, staying at v8.3.3 plus classic TextFX, for about a year, until the TextFX features I used were added to Notepad++.

                    I have also come to realize that I am not a fan of Swiss Army knives. I use one or two parts of a knife and the remainder is dead weight. TextFX was/is a very thick Swiss Army knife.

                    I’d rather use plugins or scripts that do one thing, such as adding and maintaining a <br> at the end of each like how this thread started out, or wrapping text, as this thread’s topic drifted to.

                    1 Reply Last reply Reply Quote 1
                    • S
                      Sarah Smith
                      last edited by Mar 22, 2024, 11:23 AM

                      This post is deleted!
                      1 Reply Last reply Reply Quote -1
                      • First post
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors