71

How do I replace the string "\r\n" with the same characters?

Example:

Hello World.\r\nHello World.

replaced with:

Hello World.
Hello World.
114

Press CTRL-h and the Replace dialog will open. Type \\r\\n in "Find what" and \r\n in "Replace with". Finally, select search mode Extended (\r, \n, \t, \x..., \0) and click "Replace All".

  • 2
    works in Programmer's notepad as well. Select "Allow backslash expressions" and do the same – Peter Munnings Jul 3 '12 at 19:05
  • Does that work in newer versions of Notepad++? Or does it require selecting the option "Extended (\n, \r, \t, \0, \x)"? – Peter Mortensen Feb 15 '14 at 19:14
  • 1
    Search mode has to be "Extended" to work. – Marcel Mar 19 '14 at 16:06
  • This also works in notepad2 in case anyone is interested. Check regular expression search when replacing – Hoppe Mar 31 '14 at 16:39
  • 1
    it doesn't work – Kelmen Nov 5 '15 at 5:45
9

In the find screen, on the replace tab choose extended search.
In the find text box put \\r\\n, and in the replace text box put \r\n.

  • Does this actually work, or do you need to do escaping? – Josh Hunt Sep 17 '09 at 14:21
  • 1
    I had escaping, but I had to double escape it for it to show up right here (ie \\\\r\\\\n instead of \\r\\n). – C. Ross Sep 17 '09 at 14:55
  • So did you just now have to quadruple escape that in the comment? ^^^^^^^ – hyperslug Sep 17 '09 at 15:31
  • No thankfully it doesn't try to interpret comments ... – C. Ross Sep 18 '09 at 14:55
1

Copy a newline and use the Search and Replace function to replace \r\n with the newline. The newline character will show up as an empty box.

  • 2
    I couldn't get this to work earlier. – C. Ross Sep 17 '09 at 14:56
0

I tried the top voted answer, but I couldn't get it to work for my newer version of Notepad++. I had to reverse what they did. So:

Press CTRL-h and the Replace dialog will open. Type \r\n in "Find what" and \\r\\n in "Replace with". Then select search mode Extended (\r, \n, \t, \x..., \0) and click "Replace All".

Literally what Marcus did but reversed worked for me.

  • 1
    This doesn't answer the question. – Toto Oct 23 '18 at 15:14
  • your way will convert the real the new line to the literal \r\n in the file, whereas the question is about converting the literal \r\n to new lines – phuclv Oct 23 '18 at 17:03
  • I had text just like OP in my notepad++, and it worked. Where it would literally say something like: Hello World.\r\nHello World. to be: Hello World With my version of Notepad++, doing the top voted answer did not fix it for me, but switching it did work for me. (I can't get stack overflow to register that I put a new line in between Hello and World... So just know that between Hello and World, it has a new line like how it should) – Sara Richardson Oct 29 '18 at 16:00

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.