Tried to find the answer and seen there's lots on the subject of newlines, yet I can not find the answer to this simple question.
In other editors, \n\n will find two lines but not in NP++. Nor does \n\r find anything, so, what should I use?
Plz, just an answer to this question, not some redirect as I am dizzy on how much there is on this subject. Thanks!
Hello Jep Z11,
I don't need to redirect you, at all !
Indeed, your two search regex ( \n\n or \n\r ) coudn't find any EOL, if your file has a Windows format, because :
In a file, with a Windows format, an End of Line is represented by the two characters \r\n ( \x0d\x0a )
In a file, with an UNIX/OSX format, an End of Line is represented by the unique character \n ( \x0a )
In a file, with an Old Mac format, an End of Line is represented by the unique character \r ( \x0d )
( Remenber that you can change this format of EOL in menu Edit\EOL Conversion of Notepad++ )
Moreover, the special syntax \R can search any kind of EOL. Quite nice :-)
And, as the symbol ^ represents the very beginning of a line :
A single blank line, in any format, can be matched with the regex ^\R
A list of consecutive blank lines, in any format, can be matched with the regex ^\R+
So, if you wish :
SEARCH : ^\R
REPLACE : Leave EMPTY
SEARCH : ^(\R)+
REPLACE : \1
As the form \R is enclosed in round brakets, it represents the group 1, which is re-written, in the replacement part, as a single \r\n, or \n or \r, according the the file's EOL format !
That's all !
( Tested with Notepad++ version 6.5.1 )
Thank you 'thevenot' for this clear, elaborate answer. Can see why there is so much ado on this as it requires a bit more than the average editor does. (yes, 'average'is a brand :) )
It could be better explained in the help, I couldn't find it.
NP++ is nice to me though for its features on css and html editing, so I guess I'll be a new user.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.