10

Normally I'd do a search and replace for "\n" but that doesn't seem to work.

I think it might by ^(something) but can't remember what.

Note this is question is directed at Notepad, not Notepad++. Bad Bing and Google, no biscuit!

1
  • This site suggests either ^l or ^p but I couldn't get it to work in my tests.
    – Burgi
    Nov 26, 2015 at 10:55

5 Answers 5

4

While you might just want to upgrade to a better text editor or use the Command trick mentioned by txtechhelp, but I can understand if you are looking for a simple find and replace solution instead of going toward the complicated solutions.

One such trick is to replace "your character" with <br> and saving the file as .html. Opening the html file in any browser will give you the text or csv data but with new lines added.

This way you do not need any additional software or even a line of code.

Hope that helps.

2
  • I just LOVED it!! So creative! HUGE PROPS!!!! I had an enormous file of urls that were separated by '\r\n' in Notepad. I couldn't wrap my mind around how to add actual break lines without the need to create a script!
    – testing_22
    Oct 7, 2021 at 2:46
  • @testing_22 Thanks!
    – Veki
    Oct 7, 2021 at 12:59
2

In Notepad: select from the end of a line (clicking SHIFT + Right arrow key; you can't see it, but the newline character is now selected). Now, go to "Replace" and replace with nothing. The newline characters will all be replaced with nothing.

4
  • 1
    I've just tested this, and it doesn't work here. Are you using the default Windows Notepad, or for example Notepad++?
    – MiG
    Jul 11, 2022 at 6:33
  • Another difference could be language settings, which would make your solution language specific (and if so, should be mentioned in your answer). Are you using English or another language as the OS language?
    – MiG
    Jul 11, 2022 at 6:34
  • Thanks!! it worked!
    – nicolass
    Feb 13, 2023 at 13:50
  • This worked, but in my case, I would like to add commas to the end of every line, meaning I would want to replace the newline with a comma followed by a newline. Is there any way to allow a newline character to appear in the "replace with" field?
    – Ike348
    Jun 30, 2023 at 13:47
1

There's not a direct way in Notepad itself, but if you don't want to use an external program and you're comfortable with the command line you could do something like the following:

type FILE_NAME | more /P > TEMP_FILE_NAME && move /Y TEMP_FILE_NAME FILE_NAME

This will output the file to the more command, and with the /P will expand form feed characters (i.e. change \n to \r\n) and save it to the temp file you specify .. the move /Y just automates it a little more to overwrite the old file with the \n endings with the new file with the \r\n endings.

Hope that helps.

0

Use Notepad2. It is literally the first thing I do after installing any version of Windows. Always.

Florian (the creator) has an installer that will replace the normal Notepad.exe application that ships with Windows (admin/elevation required to install it, not needed to run it). After using the installer, Notepad2 will run instead, whenever 'notepad.exe' is run.

You can also download a normal installer (installs to where ever you choose) where elevation is not required to install it, as well as the source code, etc.

Using Notepad2 for the search and replace is super simple. In the Replace text dialog, check the 'Translate backslashes' option. Then you can use \r\n, \n, \t, etc., in the Search and/or Replace text fields.

1
  • 1
    Notepad++ is also able to do that and probably more commonly known/used.
    – Cadoiz
    Apr 26, 2020 at 16:34
-1

Open find or replace & Notepad will copy & paste highlighted text, including newlines, into the find box automatically. Trying to copy & paste text into the 'replace with' box that includes a newline box sometimes works. Might depend if save was done after replaceing with a newline. This seems inconsistent.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .