In Notepadd++ the \r\n
regex will find all the CRLF
combinations. But I have some lines which end just with LF
s. First of all, what is that that? Next, how can I match and delete just that? Neither \r
or \n
works.
Notepad++ will show all of the characters with newline characters in either the CR and LF format. If it is a Windows EOL encoded file, the newline characters of CR LF will appear (\r\n). If the file is UNIX or Mac EOL encoded, then it will only show LF (\n).
In Notepad++ go to the View > Show Symbol menu and select Show End of Line. Once you select View > Show Symbol > Show End of Line you can see the CR LF characters visually. You can then use the menu item Edit > EOL Conversion and select Unix (LF).
LF stands for 'Line Feed'
You can read some more on this answer on serverfault.se:
CR LF means "Carriage Return, Line Feed" - it's a DOS hangover from the olden days from when some devices required a Carriage Return, and some devices required a Line Feed to get a new line, so Microsoft decided to just make a new-line have both characters, so that they would output correctly on all devices.
Windows programs expect their newline format in CRLF (
\r\n
). *nix expect just LF data (\n
). If you open a Unix text document in Notepad on windows, you'll notice that all of the line breaks dissapear and the entire document is on one line. That's because Notepad expects CRLF data, and the Unix document doesn't have the\r
character.There are applications that will convert this for you on a standard *nix distro (dos2unix and unix2dos)
For those wondering, a carriage return and a line feed differ from back in Typewriter days, when a carriage return and a line feed were two different things. One would take you to the beginning of the line (Carriage Return) and a one would move you one row lower, but in the same horizontal location (Line Feed)
Thus, you should be able to replace it with \n
.
Using common sense I would suggest following approach:
And you are done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With