Search code examples
emacsspacemacsdiredend-of-line

Dired appears with 015 (Octal?)


Recently, my Dired listing in Emacs starting appearing with 015 at the end of each line:

Screenshot of 015

I'm not sure what brought it on. I had been making some changes with my Spacemacs layers but since then I've gone to a completely out-of-the-box Spacemacs configuration and the 015s are still there. It makes Dired pretty much useless because if I try to select a file or drill into a directory it doesn't recognize it. Any ideas or suggestions would be greatly appreciated!


Solution

  • Those are Control M characters. Emacs writes them as either ^M (one char, not two) or \015 (again, one char, not 4).

    This Emacs Wiki page tells you about this: EndOfLineTips.

    This is some of what it says:

    If you see ^M in your file, you may have opened a file with DOS-style line endings (carriage return + line feed) while Emacs assumes it has Unix-style line endings (line feed only). (The carriage-return character, sometimes abbreviated as CR, is ^M. The line-feed character, sometimes abbreviated as LF, is ^J.)

    You can reopen the file with the correct line ending with a command like C-x C-m r dos.

    C-x C-m r is bound to revert-buffer-with-coding-system. Use C-h k or C-h f to see more about it.

    See also (C-h v) variable buffer-file-coding-system.

    Also: use i line endings in the Emacs manual, to go to node Coding Systems. That tells all you need to know about this.

    This question and its answers might also help. And see the UNIX/Linux command dos2unix.