Notepad++ find and replace string with a new-line

Notepad++ will do just fine.

Search string:

 xyz
Note the space in front of xyz.

Replace string:

\r\nxyz

You will also need to set the "Search Mode" to "Extended" (lower left group box in the Replace dialog) so that Notepad++ honors escape codes.


Some background: "\r\n" is the escape code for carriage-return, the standard for new lines in Windows. Unix-style systems use simply \n (newline). Most IDEs, Notepad++ included, will understand both styles and portray them each with new lines, but core Windows utilities do not understand \n as being equivalent to \r\n, so the latter is usually the most appropriate if the file is intended to be used in Windows environments.


In Notepad++, it's very easy...

  • Find: xyz
  • Replace with: \n


  • Search Mode: Extended (\n, \t, etc)

The trick is to set the search mode.


I cheat a bit when S&Ring characters that I can't type directly into the text fields (e.g. tabs and newlines). Find somewhere in the document which already has that character, then copy it, and paste it into the replace field.

So in your example, start at the very start of one line, click, drag to the very end of the preceeding line, copy that, and paste it into the Replace dialog.

Tags:

Notepad++