auto insert <br> at the end of every line
-
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
-
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>.
-
“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):
After this setup, press the Replace All button.
-
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!
-
@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. -
@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 -
@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?
-
@notdodgeball I am using TextFX2 with NPP 8.6.4 32-bit. It seems to work like the older TextFX, AFAICT.
-
@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. -
This post is deleted!