begin  quoting Ralph Shumaker as of Wed, Jan 31, 2007 at 12:32:21PM -0800:
> I want to know how to use vi to do search and replace.  Is there 
> something easier to use than "help" to find out how?
> 
> I want to replace all instances of
> "^[0-9][A-Z]" with
> "^[0-9] [A-Z]".

:%s/^\([0-9]\)\([A-Z]\)/\1 \2/


: -> go to command mode
% -> for every line in the file
s -> substitute
/ -> delimit the parts of the substitution
^ -> start of line
\(    -> start a group, must escape ( with \ because this is a retrofit
[0-9] -> pattern
\)    -> end of the group
\(    -> start a group
[A-Z] -> pattern
\)    -> end of the group
/  -> end the first part
\1 -> contents of first group
\2 -> contents of second group
/  -> end of substitution

> I've been making these and other changes in gedit manually.  But this is 
> one set that could be done so much faster with regular expressions.

Yup.

Don't know how to get "help" to help, as the vim help is now so huge,
it's hard to find anything unless you pretty much know what you want.

-- 
Still liking vim, even after all of these years.
Stewart Stremler


-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to