Thanks very much.
- RJA
On Nov 1, 11:33 pm, Tim Chase <v...@tim.thechases.com> wrote:
> On 11/01/11 06:03, RJA wrote:
>
> > if I have the buffer below,
>
> > ppppp 1 2 3 4 5
> > ppppp 1 2 3 4 5
> > ppppv 1 2 3 4 5
> > ppppp 1 2 3 4 5
>
> > I can type thesearch
>
> > /\(ppppp\).*\n\1.*
>
> > which will match against the first two lines
>
> > However, I want to pick out lines 2 and 3. How can I do that ?
>
> For this particular case, you cansearchfor
>
> ^\(.....\).*\n\1\@!
>
> Note that the "\@!" matches the previous atom, so if you're doing
> something more complex than the single "\1" atom, you need to
> wrap it in grouping-parens, whether capturing "\(...\)" or
> non-capturing "\%(...\)".
>
> Also note that the 4th (last) line will be matched because the
> following line doesn't start with thepatternon the current
> line. If you want to mitigate, just change thepatternto
>
> ^\(.....\).*\n\1\@!.....
>
> to assert there are 5 things there. Thosse "....." could also be
> written as ".\{5}" for what it's worth.
>
> For more reading, you can
>
> :help /\@!
>
> and the surrounding sections regarding the Perl-ish tokens.
>
> -tim
--
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