How to search/replace newlines
-
I’m trying to replace multiple newlines in a file with a single newline, but having no luck.
I tried searching for \n\n (with various options checked and unchecked), but fail to find any. I can find SINGLE newlines, but not two in a row, at least with this syntax.
Could not find any help in the app.
Any suggestions? -
Hello Chuck-Puckett,
keep in mind that windows uses \r\n as eol.
Where as unix uses \n and mac \r.Maybe \r\n does the trick.
Cheers
Claudia -
I find \r\n, and thanks for that. But my replacement attempts go astray.
What I’m trying to do is make something like thisline 1
line 2
line 3
into this:
line 1
line 2
line 3I can get of newlines in a selection by replacing \r\n with a space. But I need to eliminate empty lines.
More ideas?
-
Assuming the empty line is really empty I would use regular expression and
find what : ^$ replace with:
If you press the show all characters, is the line really empty?
Cheers
Claudia -
Didn’t think about that. Notepad++ is so much more than Notepad :)
It shows CR LF at thened of each line, CR LF in the blank lines.
Is that equivalent to ^$? -
Not really
^ marks the beginnig of a line
and $ the end.
^$ means you are looking for lines which basically have nothing then EOL chars.
Therefore replacing wouldn’t hurt other lines.Cheers
ClaudiaBtw. One thing i always forget Edit->Line operation->remove empty lines
-
Well, really, that last sentence was all I needed. :)
Tnx!
Guess it’s time I spent some time roaming around Notepad++ menus instead of thinking I’m using my grandad’s Notepad. :)