Posted By: polara
How can I find/replace all CR/LF characters in Notepad++?
I am looking for something equivalent to the ^p special character in Microsoft Word.
[rn]+ should work too
Update March, 26th 2012, release date of Notepad++ 6.0:
OMG, it actually does work now!!!
Original answer 2008 (Notepad++ 4.x) – 2009-2010-2011 (Notepad++ 5.x)
Actually no, it does not seem to work with regexp…
But if you have Notepad++ 5.x, you can use the ‘extended‘ search mode and look for
rn. That does find all your
(I realize this is the same answer than the others, but again, ‘extended mode’ is only available with Notepad++ 4.9, 5.x and more)
Since April 2009, you have a wiki article on the Notepad++ site on this topic:
“How To Replace Line Ends, thus changing the line layout“.
(mentioned by georgiecasey in his/her answer below)
Some relevant extracts includes the following search processes:
Simple search (Ctrl+F), Search Mode =
You can select an
EOLin the editing window.
- Just move the cursor to the end of the line, and type Shift+Right Arrow.
- or, to select
EOLwith the mouse, start just at the line end and drag to the start of the next line; dragging to the right of the
You can manually copy the
EOLand paste it into the field for Unix files (
Simple search (Ctrl+F), Search Mode = Extended
The “Extended” option shows
ras characters that could be matched.
As with the Normal search mode, Notepad++ is looking for the exact character.
rin a UNIX-format file will not find anything, but searching for
nwill. Similarly, a Macintosh-format file will contain
Simple search (Ctrl+F), Search Mode = Regular expression
Regular expressions use the characters
$to anchor the match string to the beginning or end of the line. For instance, searching for
return;$will find occurrences of “return;” that occur with no subsequent text on that same line. The anchor characters work identically in all file formats.
The ‘.’ dot metacharacter does not match line endings.
[Tested in Notepad++ 5.8.5]: a regular expression search with an explicit
ndoes not work (contrary to the Scintilla documentation).
Neither does a search on an explicit (pasted) LF, or on the (invisible) EOL characters placed in the field when an EOL is selected.
Advanced search (Ctrl+R) without regexp
Ctrl+M will insert something that matches newlines. They will be replaced by the replace string.
I recommend this method as the most reliable, unless you really need to use regex.
As an example, to remove every second newline in a double spaced file, enter Ctrl+M twice in the search string box, and once in the replace string box.
Advanced search (Ctrl+R) with Regexp.
The same wiki also mentions the Hex editor alternative:
- Type the new string at the beginning of the document.
- Then select to view the document in Hex mode.
- Select one of the new lines and hit Ctrl+H.
- While you have the Replace dialog box up, select on the background the new replacement string and Ctrl+C copy it to paste it in the Replace with text input.
- Then Replace or Replace All as you wish.
Note: the character selected for new line usually appears as
It may have a different value if the file is in Windows Format. In that case you can always go to
Edit -> EOL Conversion -> Convert to Unix Format, and after the replacement switch it back and
Edit -> EOL Conversion -> Convert to Windows Format.