[NTLUG:Discuss] VI editor commands

Rusty Haddock rusty at fe2o3.lonestar.org
Wed May 21 23:16:37 CDT 2003


jay linux wrote:
    >I'm refamiliarizing myself with the VI editor after a long, long time....
    >
    >Can anyone tell how I can:
    >
    >1) Find all words that start and end with a vowel.

	/\<[aeiou][a-z]*[aeiou]\>

Depends somewhat on yer definition of a "word".  Also, I tend to
run with :set ignorecase so you may need to adjust to account for
this (or turn it on like me :-).  The above search command would
require yer "word" to be at least two letters and contain nothing
but alphabetics.  This should work with old versions of 'vi'.

If single letters, such as A and I, appeal to you as words in this
context then you'll need to use this:

	/\<[aeiou]\([a-z]*[aeiou]\)*\>

    >2) replace all occurances of xxx, yyy, and zzz with Xxx, Yyy, and Zzz. In 
    >otherwords, cap the first letter of multiple words in a single VI command.

	:%s/xxx\|yyy\|zzz/\u&/g

This will find all occurances of xxx, yyy, or zzz and capitalize them
wherever they may appear.  For instance,  "fooxxxbaz" would be changed
to "fooXxxbaz".  If you need to search and replace for only words that
match xxx|yyy|zzz then you'll need something like:

	:%s/\<\(xxx\|yyy\|zzz\)\>/\u&/g

This works in Vim but I'm not sure if the '\u' special pattern was
in old versions of Vi.  I remember the \U and \L but...

Anything even remotely close here to what you want?  :-)

	-Rusty-
-- 
   _____        Rusty Haddock  =  KD4WLZ  =  rusty at fe2o3.lonestar.org
|\/   o \   o  **Out yonder in the Van Alstyne (TX) Metropolitan Area**
|   (  -<  O o   The day Microsoft makes something that doesn't suck
|/\__V__/           is the day they start making vacuum cleaners.



More information about the Discuss mailing list