Use vi / vim to remove ^M characters from files

2012.01.12 | Vim | , ,

Sometimes you’ll be handed a file from a Windows user and it will contain a bunch of “^M” characters at the end of every line. ¬†Removing them is easy, just run the command:

:%s/^M//g

To get the “^M” properly, don’t type “^” and “M”. ¬†Instead, type “ctrl + v”, then “ctrl + m”.