2

As the title says it, Notepad doesn't show line breaks, specifically \n. But in Windows Explorer, in the preview window, it does show line breaks that are just \n (really Microsoft?). After doing some experimentation, it turns out notepad actually puts a \r\n for line breaks. This is annoying because the Mac TextEdit application just puts \n and as a user who uses both Mac and Windows simultaneously for programming purposes, this is very annoying. Is there anyway to make Notepad recognize just \n as a line break? I'm not sure why it doesn't because that's just an extra byte per line and in a CSV file that can really add up.

1
  • I recommend you use notepad++.
    – user726730
    Apr 11, 2019 at 9:09

2 Answers 2

4

Yes, Microsoft uses carriage return and line feed (both characters) for end of line but only one on Mac. In development, I use Adobe Dreamweaver which you can set to solve that. I develop on both Mac and Win platforms. I am unaware of making notepad do that however. You can try Wordpad, it handles it better than notepad though.

10
  • on my windows 7 ultimate, there's a wordpad.exe in a funny directory, that wouldn't run. So I copied it from XP and that ran
    – barlop
    Jul 18, 2014 at 2:24
  • I have Win10 nowadays, you can add this to your path in your pc properties: C:\Program Files\Windows NT\Accessories if you want wordpad to work in the command prompt, or just launch it from the Cortana search prompt. May 1, 2018 at 19:05
  • Additionally, some people choose to use the third party program such as Notepad++ and set it to Unix mode which is the mode Mac is using. Wordpad does the trick and is bundled with Windows so no external program is actually needed. May 1, 2018 at 19:11
  • last time I checked, wordpad opens a file with unix line endings but saves it with windows line endings.
    – barlop
    May 2, 2018 at 0:13
  • @barlop I have been editing unix files with wordpad for years due to multi-boot computers, and the re-saved file is readable in both Macs and PCs properly (Mac and PC being what the op requested) so it works as requested. May 2, 2018 at 12:40
3

Mac is a Unix like operating system. Unix like operating systems do not use carriage return in outputting line breaks. So if you want your file show line breaks when opening it with notepad, you must first convert the file to a dos file.

So in Mac replace every occurrence of \n by \r\n

perl -pe 's/\r\n|\n|\r/\r\n/g' inputfile > outputfile

0

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