Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notepad++ How to preserve CRLF upon saving

I've got a PHP file that I need to make a simple text change to. I use FTP to copy from the linux server to my Win7 machine. I open it with notepad++, turn on -view-show symbol-view all characters- and I can see CRLF and CR before and after each line. But if I save the file and reopen the file in Notepad++, all of the CRLF's have been replaced with CR's.

How can I leave these CRLF's as they were when saving?

I am using Notepad++ 5.9.6.2

Encoding is set to ANSI. Could the file be really be encoded in another format and this be the reason why it is stripping off the information?

like image 216
DVDmmike Avatar asked Jan 22 '14 15:01

DVDmmike


People also ask

How do I put CRLF in notepad?

In Notepad++ go to the View > Show Symbol menu and select Show End of Line. Once you select View > Show Symbol > Show End of Line you can see the CR LF characters visually. You can then use the menu item Edit > EOL Conversion and select Unix (LF).

Does Notepad use CRLF?

New files created within Notepad will use Windows line ending (CRLF) by default, but it will now be possible to view, edit, and print existing files, correctly maintaining the file's current line ending format. Also note that the status bar indicates the detected EOL format of the currently open file.

What's the difference between LF and CRLF?

Whereas Windows follows the original convention of a carriage return plus a line feed ( CRLF ) for line endings, operating systems like Linux and Mac use only the line feed ( LF ) character. The history of these two control characters dates back to the era of the typewriter.


1 Answers

Notepad++ normally detects the EOL format when you open the file and will keep that format even when you save the file. When you first open one of those files, go to Edit>EOL Conversion and see which option is grayed out. That will be the current line ending format used in the file, and if you want to use a different one from the list then you can select it there. It's possible that your file has mixed line endings, in which case NPP is probably normalizing the line endings to whatever it thinks is the right one for the file when you save.

As an aside, CR is the old Mac format, meaning you've either got something messing with your file, you're accidentally setting the format yourself somehow, or you're misusing the terminology. CR=carriage return=\r, LF=line feed=\n; Windows uses CRLF (\r\n), *nix and OSX use just LF (\n), and as stated MacOS used to use just CR (\r).

like image 70
JAB Avatar answered Sep 24 '22 00:09

JAB