replacing ^M with emacs

Giorgos Keramidas keramida at
Mon Oct 30 08:03:58 UTC 2006

On 2006-10-28 04:18, Tsampros Leonidas <ltsampros at> wrote:
> I think there is something similar in emacs by using the
> set-buffer-file-coding-system (binded at C-x RET f in default
> configurations).
> So to "cure" and succesfully "convert" DOS files into unix format, i
> use C-x RET f unix RET.

I'm not sure `set-buffer-file-coding-system' will have any effect on an
already opened file though.  I just tried this with a file which was
created outside Emacs, and contained:

    $ cat -vte foo 

Opening this file with `C-x C-f foo RET' and setting the buffer file
coding system with `C-x RET f unix RET', marks the buffer as modified,
but saving the file does not modify the contents of the file to use UNIX
newlines only.

If you really want to use Emacs for the conversion, you have to
*explicitly* replace ^M characters, either with `M-x replace-string RET
C-q C-m RET RET' or some either way.

More information about the freebsd-questions mailing list