On the left side of the modeline, you'll see (DOS)
. This means that Emacs is viewing the buffer as if it had DOS-style line endings. To view the buffer as if it had Unix-style line endings, use the command revert-buffer-with-coding-system
(bound to C-x RET r
or C-x C-m r
), and select something like utf-8-unix
. Then the ^M
characters will be visible.
Alternatively, if you want to convert the file to Unix-style line endings, use set-buffer-file-coding-system
(C-x RET f
/C-x C-m f
) and choose utf-8-unix
, then save the buffer.
From the Emacs manual, 22.6 Recognizing Coding Systems:
Emacs recognizes which kind of end-of-line conversion to use based on the contents of the file: if it sees only carriage-returns, or only carriage-return linefeed sequences, then it chooses the end-of-line conversion accordingly. You can inhibit the automatic use of end-of-line conversion by setting the variable inhibit-eol-conversion to non-nil. If you do that, DOS-style files will be displayed with the ‘^M’ characters visible in the buffer; some people prefer this to the more subtle ‘(DOS)’ end-of-line type indication near the left edge of the mode line (see eol-mnemonic).
http://www.gnu.org/software/emacs/manual/html_node/emacs/Recognize-Coding.html