> Not being an expert at regex I have been a bit baffled by how to do a
> grep/vimgrep to match. I am probably stepping on my own foot as I
> think I have done such in the past but have not been readily able to
> do this. Can anyone point me in the right direction?
>
> I am trying to find all lines which begin with 'has_text?' but does
> not contain the predicate '.should eq(true)', so this line should get
> matched and returned in the grep results:
>
> has_text?('some text','td')
>
> But not this one:
>
> has_text?('some text','td').should eq(true)
>
> I have tried a number of things such as the following but having
> trouble getting the 'does not match' predicate to work:
>
> vimgrep /\(has_text?\).*^\(\.should\)/
>
You might try
^\s*has_text\%(\%(\.should eq(true)\)\@!.\)*$
(the "\s*" is optional, depending on whether you want to allow
leading whitespace before the "has_text").
This is might also be a bit less painful with Dr. Chip's
LogiPat.vim script/plugin.
-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