From the https://www.emacswiki.org/emacs/EndOfLineTips
You can reopen the file with the correct line ending with a command like M-x revert-buffer-with-coding-system utf-8-dos
. If your file is not in Unicode, be sure to specify the correct encoding system instead of utf-8-dos
Dos uses CR+LF
end of line, when UNIX uses only LF
. CR
sometimes looks like ^M
. For viewing ^M
you must use M-x revert-buffer-with-coding-system utf-8-unix
. This will use LF
as end of line and indicate CR
like ^M
instead of Dos which uses CR+LF
as end of line.
Disable autodetect: not sure it needs. If you want to convert files into UNIX format, then open DOS file and set line ending with M-x set-buffer-file-coding-system utf-8-unix
, this command will convert all CR+LF
into LF
.
If you can edit the file, you could open file with a certain coding system with -*- coding: utf-8-unix; -*-
at the first or second line in the file.