Replace \r\n with newline in Notepad++

85

12

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

Example:

Hello World.\r\nHello World.

replaced with:

Hello World.
Hello World.

C. Ross

Posted 2009-09-17T13:59:14.330

Reputation: 5 284

Answers

136

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

drrlvn

Posted 2009-09-17T13:59:14.330

Reputation: 4 695

You could also do what I did and turn off extended search then replace \r\n with some unique string like "~~~~" then turn extended search back on and replace that string with \r\n. An extra step but it works. – Steve Hiner – 2014-10-04T00:11:26.823

1it doesn't work – Kelmen – 2015-11-05T05:45:37.427

I had to replace it with \r\n but it did work – runxc1 Bret Ferrier – 2018-07-10T21:51:37.230

2works in Programmer's notepad as well. Select "Allow backslash expressions" and do the same – Peter Munnings – 2012-07-03T19:05:00.633

Does that work in newer versions of Notepad++? Or does it require selecting the option "Extended (\n, \r, \t, \0, \x)"? – Peter Mortensen – 2014-02-15T19:14:21.110

1Search mode has to be "Extended" to work. – Marcel – 2014-03-19T16:06:24.323

This also works in notepad2 in case anyone is interested. Check regular expression search when replacing – Hoppe – 2014-03-31T16:39:27.273

10

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.

C. Ross

Posted 2009-09-17T13:59:14.330

Reputation: 5 284

Does this actually work, or do you need to do escaping? – Josh Hunt – 2009-09-17T14:21:32.343

1I 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 – 2009-09-17T14:55:25.220

So did you just now have to quadruple escape that in the comment? ^^^^^^^ – hyperslug – 2009-09-17T15:31:52.697

No thankfully it doesn't try to interpret comments ... – C. Ross – 2009-09-18T14:55:50.777

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.

Sara Richardson

Posted 2009-09-17T13:59:14.330

Reputation: 11

1This doesn't answer the question. – Toto – 2018-10-23T15:14:49.747

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 – 2018-10-23T17:03:50.540

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 – 2018-10-29T16:00:19.497

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.

Linus

Posted 2009-09-17T13:59:14.330

Reputation: 679

2I couldn't get this to work earlier. – C. Ross – 2009-09-17T14:56:11.490