Removing ^M characters in VI

When porting a text file from Windows to UNIX you will quite often get a ^M on the end of every line. Apart from look bad and make it hard to read, if you text file happens to be a script, then this can also effect the way your script is run.
To remove the ^M characters at the end of all lines in vi, use this command.
:%s/^V^M//g
To get the ^V you need to type Control+V and Control+M for the ^M. However when you type this, it will appear on the screen like this:
:%s/^M//g
Continue reading Removing ^M characters in VI