Tuesday, November 30, 2010

Re: Pattern limits selection for next pattern or substitution

Thanks Tinou and Geoff.

@Geoff

That thread was just what I needed. The one that's just a tad off is
that before attaching the XXX prefix, it has to find the pattern
"start" and "end". At first, I thought that after finding a match, it
attaches a "start" to indicate the beginning of the mark, and "end" to
indicate the end. It looks as if you have to add "start" and "end"
yourself to bound the selection.

I'll try to figure out how to find the match, move up a bit to add a
start prefix, and then move down to add a postfix. I can then use
those to restrict the search.

On Nov 30, 3:57 am, lessthanideal <geoffrey.w...@thomsonreuters.com>
wrote:
> 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/61fef2ed8...

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