[TriLUG] vi question
Aaron Schrab
aaron at schrab.com
Wed Jul 16 13:38:32 EDT 2008
At 13:25 -0400 16 Jul 2008, Greg Brown <gwbrown1 at gmail.com> wrote:
>I'm trying to match multiple commas in a line in vi so I can globally change
>them to a single comma (yup, I'm building a .csv file).
>
>Here's an example line::
>
>,101.5000,WRAL,,,,,,,,,,,,,,,,,,,,,,Raleigh,,,,,,,,,,,,,,BF,,,,,,,,,,,,,,,,,,,,,,,Rock
>
>The leading comma is ok, I really don't care about that, it's easy enough to
>strip out.
>
>:1,$s/\,+/\,/g is NOT working. Grr. Any hints? I know I'm overlooking
>something extraordinarily simple here....
Real vi doesn't support the + modifier. Vim (and possibly other
enhanced vi implementations) has support for this type of modifier, but
to avoid breaking compatibility it uses \+ instead of just +. By itself
+ is taken literally.
The comma isn't a special character, so it doesn't need to be backslash
escaped, although it doesn't currently cause problems.
More information about the TriLUG
mailing list