^M at the end of every line in vim ^M at the end of every line in vim windows windows

^M at the end of every line in vim


As a command, type

:%s/^M$//

(To get ^M, press ^V ^M, where ^ is CTRL on most keyboards)


One easy way to strip out the DOS line endings is to use the ff option:

:set ff=unix:wq

Now your file is back to the good-old-Unix-way.

If you want to add the DOS line-endings (to keep a printer happy, or transfer files with Windows friends who don't have nice tools) you can go the opposite direction easily:

:set ff=dos:wq


You can do this:

:set fileformats=dos

It will hide the ^M's, without touching the file.