Why does Emacs insert ^m at the end of every line in my Linux environment?

link|improve this question

65% accept rate
feedback

1 Answer

up vote 9 down vote accepted

Emacs Line Return and Windows, Unix, Mac, All That ^M ^J ^L

Q: Why does emacs show ^M in a buffer?

A: The “^M” is ASCII caret notation for unprintable Carriage return char (ASCII 13). If emacs shows that, it's probably because you have mixed characters of ^M and ^J and emacs cannot interpret them consistently as newlines.

To fix it, call “set-buffer-file-coding-system”, then give one of: “mac”, “dos”, “unix”. Then, save the file. If that does not fix it, you can use find and replace to remove it manually.

link|improve this answer
As an addendum C-x RET f is the key chord for set-buffer-file-coding-system, so you can type that instead. I never remember it, though. – quodlibetor Apr 24 '11 at 3:26
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.