Removing ^M Characters In Vim

If you edit files in gedit or notepad and ^M characters would be

inserted. After that you could not simply remove ^M in VIM with

the following command:

%s/^M//g
%s/\^M//g
%s/^V^M//g
%s/C-vC-m//g

As pattern was not found.

^M in VIM can be manipulated as it is an \r character, which is read

as carriage return. Doing a replace for \r characters will

remove the ^M:

%s/\r//g

Your file would also contain \0, which is null-byte. Remove them too:

%s/\0//g

\n represent new line. Replace it will get a single line file:

%s/\n//g

##for more information

" " (ASCII 32 (0x20)), an ordinary space.
"\t" (ASCII 9 (0x09)), a tab.
"\n" (ASCII 10 (0x0A)), a new line (line feed).
"\r" (ASCII 13 (0x0D)), a carriage return.
"\0" (ASCII 0 (0x00)), the NUL-byte.
"\x0B" (ASCII 11 (0x0B)), a vertical tab.