Is there a way to tell GNU Emacs to convert DOS/Windows newline characters in a file to Unix format?
If the mode line shows a
(DOS) indicator, click on it twice to cycle to
: meaning Unix newlines and then save the file.
If you can't click on the mode line or prefer a keyboard-based solution, run the command
C-x RET f (
set-buffer-file-coding-system) and type
unix. This will change the encoding of newlines without changing the encoding of other characters. (You can also change the encoding of other characters by typing something like
Save the file, and Emacs will automatically use the correct newline char when writing the buffer to file, according to the value of
To know what is the value of buffer-file-coding-system, call
buffer-file-coding-system, or run the
describe-coding-system command which you can do by clicking the second character of the mode line or pressing
C-h C. To set its value, call
C-x RET f) and tab to choose the one you want.