I'm just learning emacs and I'm using spacemacs configuration. I created a
.org file and everything looks normal when I save it, but when I reload it I get a whole bunch of
^M chars at the end of each line. How do I avoid this?
^M is the "carriage return" character. DOS and Windows computers use the two-character sequence
^M^N to mark the end of every line, while Linux uses just
^N (the "line feed" character).
There are a number of Emacs settings which can control how files are encoded when saving them and when opening them, but by default it simply assumes that files will have the proper line endings for the system you're running. Thus, if you're on Linux then Emacs will assume that files have only
^N characters at the end of every line, and that
^M characters have no special meaning.
It sounds like you choose to save the file in a specific encoding, such as
us-ascii-dos, which caused it to use the DOS line endings instead. There are a number of different ways you can get into that state, so I'm not going to try to guess how you did it. If it asked you to choose a coding system when you saved the file, then just don't choose one with
-dos in the name next time.