On Oct 10, 2:08 am, "Dmitry Teslenko" <[EMAIL PROTECTED]> wrote:
> Hello!
> Does vim support multiline patterns with pockets?
> If it does, then what pattern would match this:
>
> {
>         Type * variantName = ....;
>         variantName->someMethod();
>
> }
>
> i.e. search all places where variable of type "Type" was used,
> "someMethod" was called and variant name may vary.
>

I don't actually know what you mean by "pockets".

One pattern that might work:

/Type\s*\*\s*\(\k\+\)\s*=\_.\{-}\zs\1->someMethod()

It could potentially be very inefficient, though. Also, it has no
knowledge of the scope of the variable.

Explanation:

Type\s*\*\s* : match "Type *" with any amount of whitespace
\(\k\+\) : match any keyword characters and store it in a
backreference for later
\s*= : match any whitespace and an '=' character (you've indicated
this is what you want).
\_.\{-} : match _as_little_as_possible_ of any character (including
newlines) before you match the following
\zs : start the match here (the cursor will be placed here when you
search)
\1 : match the 1st backreference, which is the variable name you want
->someMethod() : match the method name
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to