How can I replace empty lines in Notepad++? I tried a find and replace with the empty lines in the find, and nothing in the replace, but it did not work; it probably needs r
There is now a built-in way to do this as of version 6.5.2
Edit -> Line Operations -> Remove Empty Lines
or Remove Empty Lines (Containing Blank characters)
^\R
( for exact empty lines) or ^\h*\R
( for empty lines with blanks, only).This obviously does not work if the blank lines contain tabs or blanks. Many web pages (e.g. http://www.guardian.co.uk/) contain these white lines, as a result of a faulty HTML editor.
Remove white space using regular expression as follows:
change pattern: [\t ]+$ into nothing.
where [\t ] matches either tab or space. '+' matches one or more occurrences, and '$' marks the end of line.
Then use notepad++/textFX to remove single or extra empty lines. Be sure that these blank lines are not significant in the given context.
/n/r
assumes a specific type of line break. To target any blank line you could also use:
^$
This says - any line that begins and then ends with nothing between. This is more of a catch-all. Replace with the same empty string.
In notepad++ press CTRL+H , in search mode click on the "Extended (\n, \r, \t ...)" radio button then type in the "Find what" box: \r\n (short for CR LF) and leave the "Replace with" box empty..
Finally hit replace all
Ctrl+H.
find - \r\r replace with - \r.