tags:

views:

104

answers:

4

I need to replace empty lines in notepad ++. I have tried a find and replace with the empty lines in the find, and nothing in the replace, but it did not work. Probably need regex. Thanks in advance for your help.

+1  A: 

Yes, you need a regular expression.

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.

Brad
+4  A: 

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

Link-
typo sorry about that..
Link-
@Link, actually, I tried it, see my clarification in my answer. *You were on to something!*
Brad
This assumes the line endings are Windows (CRLF) though, if your file is saved with Unix line endings search only for `\n`.
BoltClock
@Brad: I wrote in between the () "short for CR LF", didn't want codetrek to think \n is CR, hence the edit.
Link-
A: 

Well I'm not sure about the regex or your situation..

How about CTRL+A, Select the TextFX menu -> TextFX Edit -> Delete Blank Lines and viola all blank line gone.

A side note - if the line is blank i.e. does not contain spaces, this will work

Ahmad
A: 

There is a menu entitled TextFX. This menu, which houses a dizzying array of quick text editing options, gives a person the ability to make quick coding changes. In this menu, you can find selections such as Drop Quotes, Delete Blank Lines as well as Unwrap and Rewrap Text

Do the following:

TextFX > TextFX Edit > Delete Blank Lines
TextFX > TextFX Edit > Delete Surplus Blank Lines
Harpreet