Emacs: Change a File's Line Endings
Change File Line Ending Between Windows, Linux, Mac
- Open the file
- Alt+x
set-buffer-file-coding-system
. - Type one of: mac, dos, unix. (on Mac, use “unix”. For Microsoft Windows, use “dos”.)
- Save the file.
If you want utf-8 encoding, chose one of:
utf-8-dos
→ Microsoft Windowsutf-8-unix
→ Unix, Linux, MacOSXutf-8-mac
→ classic Mac OS (dated before 2002)
Which newline convention is used for the current file?
See the value in variable buffer-file-coding-system 〔see Emacs: Show Variable Value〕