This is how you remove those annoying ^M characters that show up in files previously edited on a Windows/DOS platform.
:%s/[ctrlkey+v and ctrl-key+M]//g
Here’s a walk through video I made. My first actually
Damn.. i was thinking of doing screencasts as well.
Good job man.
Thanks sir, more to come. It’s fun 😀
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?
i found this to work on windows xp
to replace all ^M with nothing in the whole file
Thanks for sharing the solution ciprian.
Thanks man, very helpful.
Hi Ciprian, i am editing the file vi putty remoting from win 2008 SBS and the command %s/\r//g does’t seems to work either.
Thanks in advance
You are remoting into a linux box or win xp box?
If linux then pres %s/Ctrl-VCtrl-M//g
The Ctrl-VCtrl-M should show up like a ^M
If on windows i dont know of any other way besides %s/\r//g
Let us know if you find out
But I dont want to open the file using VI and then type at :
Can i just do it without opening the file ?
Awesome you saved about 1 hr for me
Thanks a lot
You might consider just running dos2unix utility on the file.
How can you do that without using VI? I mean, I want to include that in a UNIX script.
Lean, do a dos2unix
the below command will clear the ^M character