Monday, November 29, 2010

Pattern limits selection for next pattern or substitution

Hi

I'm wondering if it's possible to do this in Vim:
You put up a command with a pattern, and the command selects the line
(or offsets to select a few surrounding lines in addition to the line)
that contains the pattern. Once all these lines that contain the
pattern are selected, I want to do a pattern search and pattern
substitution that is limited to only those lines that were selected by
the first pattern.

I came across this search/replace in a visual selection link:
http://vim.wikia.com/wiki/Search_and_replace_in_a_visual_selection

:'<,'>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

--
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:

Post a Comment