Tuesday, November 30, 2010

Re: Pattern limits selection for next pattern or substitution

On Tue, Nov 30, 2010 at 08:44, bboyjkang <jkang61@gmail.com> wrote:
> :'<,'>s/red/green/g
>
> I would like the :'<,'> to be instead a (does it have to be visual?)
> selection of all those lines that contain the pattern. Then, I could
> do a substitution, or a pattern search that might further restrict the
> selection.
>
> Thanks for any help

Hello,

To replace all occurrences of "red" by "green" in the current file, you can use:

:%s/red/green/g

Another handy command is :g. With it you can replace all "red" by
"green" where "blue" is:

:g/blue/s/red/green/g

:he :s
:he current-file
:he :g


Tinou

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: