[UCLA-LUG] Getting rid of "^M"s in vi

Joshua Uziel uzi@linuxcare.com
Fri, 7 Jul 2000 17:33:30 -0700


* James Lee <jwlee@ucla.edu> [000707 15:53]:
> "CHEN,THOMAS" wrote:
> > I'm editing a text file that displays a lot of "^M" instead of carriage
> > returns.  How do I get vi to interpret and display them as such?
> 
> try :%s/\r//g or you can write a shell script to do it...

Another way (that I use, and I think it's more direct) is to do

        :%s/^V^M//g

Which will look like you typed

        :%s/^M//g

Basically, the Control-V means that the next control should be taken
literally as a character...

-- 
Joshua Uziel, Senior Linux Consultant, Linuxcare, Inc.
415.354.4878 tel, 415.701.7457 fax
uzi@linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.