On Wednesday, April 24, 2013 9:54:14 PM UTC+12, Christian Brabandt wrote:
> ... somehow behave consistent to the forwarding search?

Search *patterns* match from a point then implicitly forward, even if the 
search is backward.  So ?^\(foo\n\)\+ matches on line 5, the pattern doesn't 
cross lines backwards.

You can chain searches together with ; though.  To search backwards for a line 
beginning with foo, then backwards for a line not beginning with foo, then 
forward one line:

 ?^foo?;?^\(foo\)\@!?+

That doesn't work if the foos start on line 1, the + offset won't wrap around 
the file end or beginning, (this appears to me to be undocumented).  If that's 
a problem,

 ?^foo?;?^\(foo\)\@!?;/^foo

will work ('ws' being on).  Unfortunately, back references don't reach across 
the ;, so if your "foo" was long, you might want to use a variable:

:let p = "foo"
:exe '?^' . p . '?;?^\(' . p . '\)\@!?;/^' . p

HTH, John Little

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to