When you work with vim, you find out some character like ^M.

That is because Unix uses 0xA for a newline character. Windows uses a combination of two characters: 0xD 0xA.

0xD is the carriage return character. ^M haapens to be the way vim displays 0xD(0x0D=13, M is the 13th letter in the English alphabet).

If you want to remove the character(^M) in vim. run the following in command mode:

%s/^M//g

Where ^M is entered by holding down Ctrl and typing v followed by m, i.e. pressing Ctrl and simultaneously pressing “v” and then “m”.

after that, release Ctrl.

This expression will replace all occurences of ^M with the empty string(i.e. nothing).

Normally It is used to get rid of ^M in files copied from Windows to Unix such as Solaris, Linux, OSX)

Reference