EOL conversion in notepad ++
For some reason, when I open files from a unix server on my windows machine, they occasionally have Macintosh EOL conversion, and when I edit/save them again they don't work properly on the unix server. I only use notepad ++ to edit files from this unix server, so is there a way to create a macro that automatically converts EOL to Unix format whenever I open a file?
That functionality is already built into Notepad++. From the "Edit" menu, select "EOL Conversion" -> "UNIX/OSX Format".
screenshot of the option for even quicker finding (or different language versions)
You can also set the default EOL in notepad++ via "Settings" -> "Preferences" -> "New Document/Default Directory" then select "Unix/OSX" under the Format box.
-
7I know about the conversion in the edit menu, and the settings you mentioned are only for new documents. I want to automatically make the conversion for every file I open (or every file I save) – Jeff May 1 '13 at 16:04
-
The problem is when I open an existing Unix file, the "EOL Conversion" --> UNIX/OSX Format is greyed out. Notepad++ is to frustrating to use with UNIX files, so I use Notetab Lite which allows me to save All files as UNIX, not just new ones. – Off The Gold Dec 29 '16 at 16:37
-
3@OffTheGold The UNIX EOL option is greyed out because it is the current selection. – blakeoft Jun 6 '17 at 15:47
-
RIght on. Thank you from November 2017 via Google. – SDsolar Nov 8 '17 at 21:49
-
This is no working for me. I keep selecting "EOL Conversion -> Unix", but it does nothing. I go back into the menu and see that Windows is the greyed out (therefore selected?) option, so I click Unix again. I even tried to select-all my text first in case it only works on selection, then selected Unix again. Still it does nothing. – Loduwijk Oct 18 '19 at 17:46
In Notepad++, use replace all with regular expression. This has advantage over conversion command in menu that you can operate on entire folder w/o having to open each file or drag n drop (on several hundred files it will noticeably become slower) plus you can also set filename wildcard filter.
(\r?\n)|(\r\n?)
to
\n
This will match every possible line ending pattern (single \r, \n or \r\n) back to \n. (Or \r\n if you are converting to windows-style)
To operate on multiple files, either:
- Use "Replace All in all opened document" in "Replace" tab. You will have to drag and drop all files into Notepad++ first. It's good that you will have control over which file to operate on but can be slow if there several hundreds or thousands files.
- "Replace in files" in "Find in files" tab, by file filter of you choice, e.g., *.cpp *.cs under one specified directory.
Binary
in order to keep line endings preserved. So, you may be able to reconfigure your FTP/SCP/etc program to transfer the files in a different manner. – Slicktrick Feb 22 '17 at 22:11