Tuesday, November 30, 2010

Re: Pattern limits selection for next pattern or substitution

On Nov 30, 7:44 am, bboyjkang <jkan...@gmail.com> wrote:
> 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

Does this recent thread answer your question? [1] In the first step of
Tim Chase's answer maybe he does what you want. Where he tacks on a
unique prefix with s/^/XXX/ that is a standard search/replace command.

If you specifically want to *select* a set of lines, i.e. use select
or visual mode or similar, I'm not sure.

regards, Geoff

(Link all one line)

[1] http://groups.google.com/group/vim_use/browse_thread/thread/61fef2ed829022bb#

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