Notepad++: Find and Replace with Carriage Return
I need to do a find and replace in a large text file, but I want to replace the found text with a carriage return (as if I had hit the return key on the keyboard) instead of general text.
Use Notepad++’s Extended Search mode!
Do a normal find and replace to bring up the Find dialog
Select the Replace tab
In the Search Mode section at the lower left, select Extended
Enter your search term in the Find what: text field at the top
Enter \r\n in the Replace with: text field
Every found instance will be replaced with a carriage return now
Hint: enter \r\n\r\n for two returns!
An interesting work around using other text editors:
You can search and replace by CR in Notepad (works for CSV purposes) by:
- Firing up Excel, and typing Alt-Enter in a cell to enter a CR
- Saving this file as CSV
- Opening this CSV in Notepad – the CR will be shown as a blank square
- Copy this square and paste it into Replace
- When replace is done, CR will be there, and can be interpreted (though not with Notepad – but Wordpad will do it, so will Excel…)
APPLIES TO / KEY WORDS
Find and Replace