108

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

Example:

Hello World.\r\nHello World.

replaced with:

Hello World.
Hello World.

4 Answers 4

190

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".

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

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.

4
  • Does this actually work, or do you need to do escaping?
    – Josh Hunt
    Sep 17, 2009 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, 2009 at 14:55
  • So did you just now have to quadruple escape that in the comment? ^^^^^^^
    – hyperslug
    Sep 17, 2009 at 15:31
  • No thankfully it doesn't try to interpret comments ...
    – C. Ross
    Sep 18, 2009 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.

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

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.

3
  • 1
    This doesn't answer the question.
    – Toto
    Oct 23, 2018 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, 2018 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) Oct 29, 2018 at 16:00

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