How to remove ^M character with VI
17 Jan, 2008 | Posted by
Danesh | in
HowTo,
Linux
This is how you remove those annoying ^M characters that show up in files previously edited on a Windows/DOS platform.
In VI,
:%s/[ctrlkey+v and ctrl-key+M]//g
actual command,
:%s/^V^M//g
Here’s a walk through video I made. My first actually
Tags:
HowTo,
Linux,
microsoft,
vi
Raja | January 17th, 2008 at 11:38 pm #
Damn.. i was thinking of doing screencasts as well.
Good job man.
Danny | January 18th, 2008 at 12:11 am #
Thanks sir, more to come. It’s fun
ciprian | February 7th, 2008 at 4:33 am #
hi, the ^M are showing for me on windows xp, i tried this command %s/^M//g but it doesn’t work, as soon as i put in the ctrl-m it says it cant find the pattern, is there some difference that i have to do to get to use this command on windows?
ciprian | February 7th, 2008 at 4:48 am #
i found this to work on windows xp
%s/\r//g
to replace all ^M with nothing in the whole file
Danny | February 9th, 2008 at 3:42 am #
Thanks for sharing the solution ciprian.
Liberta Design | June 29th, 2008 at 11:00 pm #
Thanks man, very helpful.