find and replace end of line with "\n" verbatim

jennifer.cl picture jennifer.cl · Mar 14, 2013 · Viewed 95k times · Source

I am hoping to use some text editor to find all the "end of lines" in a document and replace them with just the written sequence "\n" (for ease of conversion into another file type). I've been trying with both Notepad++ and textpad with little luck.

When using regular expression mode on Notepad++ for example, I will type in [Find: \n] in the find field (which it will find successfully) and [Replace: \Q\n\E] in the replace field (the \Q and \E being verbatim search modifiers as far as I can tell), with no encouraging effects.

Is there an easy way do accomplish this replacement?

Answer

nitsua picture nitsua · Mar 14, 2013

In the notepad++ search & replace dialog (Ctrl-H), go into "Extended" mode.

From there, replacing \r\n with \\n should do it - if I understand your question correctly.

For instance, I typed in...

something
something else
blah

... and then did the above with "Replace All", which left me with:

something\nsomething else\nblah