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.

- 73,866
- 12
- 100
- 156

- 14,597
- 32
- 109
- 229
-
Are you sure `\n` doesn't work? – BoltClock Sep 20 '13 at 19:03
-
1@BoltClock it matches CR and CR/LF combinations.. – 1252748 Sep 20 '13 at 19:32
3 Answers
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
.
-
-
-
@thomas Updated my answer with some pictures of how I used `\n` to remove the `LF` characters. – Jerry Sep 20 '13 at 19:53
-
And disregard the regex in the background, it was something I was trying and it was left there for I don't know how long =P – Jerry Sep 20 '13 at 19:54
-
Thanks. I don't know why that doesn't work for me. I'm not even sure how you got the LFs on a line by themselves. – 1252748 Sep 20 '13 at 19:55
-
@thomas The `CR` are carriage returns and I just replaced `\r` by nothing. :) – Jerry Sep 20 '13 at 19:56
Using common sense I would suggest following approach:
- Replace all the CRLFs with some special string (that you are sure is not present in file), say "fuuuuuu!!!".
- Replace LFs with empty string.
- Replace all the special strings ("fuuuuuu!!!") back with CRLF.
And you are done.

- 668
- 5
- 22
-
1
-
This seems the right answer. Problem was to replace only \n and let \r\n as is eventually. – nee21 Mar 30 '16 at 19:25