Use vi / vim to remove ^M characters from files

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:


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

Leave a Reply

Your email address will not be published. Required fields are marked *