Unix uses 0xA for a newline character. Windows uses a combination of two characters: 0xD 0xA. 0xD is the carriage return character. ^M
happens to be the way vim displays 0xD.
You can remove all the ^M
characters by entering the following:
:%s/^V^M//g
where ^V^M
means CTRL+V,CTRL+M and is a way to entering characters ^M
into vi. It will globally replace all occurrences of ^M
with nothing.