Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing empty lines in Notepad++

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 regex.

like image 789
nomoreflash Avatar asked Oct 05 '10 17:10

nomoreflash


People also ask

How do you remove blank lines in a text file?

Open TextPad and the file you want to edit. Click Search and then Replace. In the Replace window, in the Find what section, type ^\n (caret, backslash 'n') and leave the Replace with section blank, unless you want to replace a blank line with other text. Check the Regular Expression box.

How do you Find blank lines in NotePad?

You can use \r\n to find blank lines from text files made within Windows, \r for Mac and \n for Linux.


2 Answers

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)

Screenshot of removing empty lines

like image 58
Halfwarr Avatar answered Sep 24 '22 20:09

Halfwarr


You need something like a regular expression.

You have to be in Extended mode

If you want all the lines to end up on a single line use \r\n. If you want to simply remove empty lines, use \n\r as @Link originally suggested.

Replace either expression with nothing.

like image 30
Brad Avatar answered Sep 24 '22 20:09

Brad