[CLUE-Tech] vi command

Todd A. Gibson tgibson at augustcouncil.com
Tue Apr 23 13:04:01 MDT 2002


On Mon, Dec 31, 2001 at 05:08:13PM -0700, Timothy C. Klein wrote:
> * jbrockmeier at earthlink.net (jbrockmeier at earthlink.net) wrote:
> > On Mon, 22 Apr 2002, Kevin Cullis wrote:
> > 
> > Is this really any better? I mean typing 
> > :%s/yes, doctor /\uyes, \udoctor/
> > 
> > is more time consuming than typing
> > :%s/yes, doctor /Yes, Doctor/
> 
> Nah, it would just be *way* easier to use the '~' command.  The above
> modifiers really shines, though, when it is not clear what work may be
> matched by the expression on the right, and you are saving in a /( /)
> construct.  That is not the case in this simple example, though.  

Yup, \u is a a wonderful tool to use with backreferences.  I didn't know
about the \u construct.  A nice bit of knowledge to have.
Let's you do things like convert 
From:
some_function()
another_algorithm()
To:
someFunction()
anotherAlgorithm()

:%s/\([A-z0-9]*\)_\([^(]*\)/\1\u\2/g

Not a perfect regular expression perhaps (it doesn't take advantages of
vim's extended RE's for one thing), but a start...

 
> The g~w command mentioned erlier seems to be the best.  Does anyone know
> if this is just vim, or also a vi thing?

It's a vim thing.  The character "g" is not mapped to anything in
vanilla vi.
-TAG



More information about the clue-tech mailing list