[lug] Beautify in vi

John Starkey jstarkey at advancecreations.com
Thu Mar 29 23:06:59 MST 2001


Thanks everyone for the help.

I was trying 1,$s/\^M//g or something or other. I didn't know about putting ^v
instead of the escape.

As far as the dos thing. It's been a while since I uploaded these files. I could
have opened them in HomeSite and saved them via samba to the linux box. But it's
been so long since I editted these files, they were at the beginning of a long
project. But I do get these occasionally when doing a script command. So I may
not be able to blame it on Wincrap this time.

Thanks again,

John

Deva Samartha wrote:

> John,
>
> it would be more clear if you would post a sample of the stuff you get.
>
> If it's ^M's at the end of the line, it could be DOS formatted text, but
> this does not make sense when going from Linux to BSD. If it is some other
> file containing control characters it's a different issue.
>
> The vi command mentioned here:
>
> %s/<clt-v><ctl-m>//g
>
> substitutes (s) globally (%) the control character CR or '\r' or carriage
> return (<clt-v><ctl-m>) with nothing (//) in multiple occurrences on the
> same line (g).
>
> The <ctl-v> tells vi to take the next character as a literal control
> character and deal with it and got nothing to do with vi's trust. This does
> not work with LF.
>
> man ascii gives you the ascii characters:
>
>         Oct   Dec   Hex   Char           Oct   Dec   Hex   Char
>         ------------------------------------------------------------
> ..
>         012   10    0A    LF  '\n'       112   74    4A    J
> ..
>         015   13    0D    CR  '\r'       115   77    4D    M
>
> where you can see the relationship between control characters and printable
> characters.
>
> Samartha
>
> At 03:57 PM 3/29/2001 -0700, you wrote:
> >He's right indeed.  Duh.
> >
> >So, that's <ctrl-v><ctrl-m> between the leaning toothpicks.  The literal
> >carret (^) in a regex means "at the beginning of a line,"
> >which is not what you want.
> >
> >"Holshouser, David" wrote:
> > >
> > > It's slightly more difficult than that in my experience.
> > > :%s/^v^m//g
> > >
> > > the ^v says don't look at my next keystroke, just trust me.
> > >
> > > > -----Original Message-----
> > > > From: John Hernandez [SMTP:John.Hernandez at noaa.gov]
> > > > Sent: Thursday, March 29, 2001 3:45 PM
> > > > To:   lug at lug.boulder.co.us
> > > > Subject:      Re: [lug] Beautify in vi
> > > >
> > > > :%s/^M//g
> > > >
> > > > John Starkey wrote:
> > > > >
> > > > > I have several files that I transfered from linux to FreeBSD. On the
> > > > > FreeBSD server the command chars are showing up. Mainly ^M. I saw that
> > > > > set: beautify is supposed to clean those out. But it isn't and I found
> > > > > one doc that says it only does so when reading into a file. I tried
> > > > > creating a new file and reading the old one into it. Still no luck.
> > > > >
> > > > > Anyone know of something I could do to strip these automatically?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > John
> > > > >
>
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug




More information about the LUG mailing list