On Mon, Nov 13, 2006 at 04:35:51PM -0500, Jean-Rene David wrote:
> Is there any way to search for text in open folds
> only? For example, if fold 1 and fold 2 below are
> closed and fold 3 is open, and placing the cursor
> on the line which says "Start search here", I
> would like to end up on the "foo" in fold 3 when
> typing "/foo<CR>".
> 
> Start search here
> 
> {{{
>    fold1
>    foo
>    fold1
> }}}
> {{{
>    fold2
>    foo
>    fold2
> }}}
> {{{
>    fold3
>    foo
>    fold3
> }}}
> 
> -- 
> JR
>  vim: fdm=marker

     It helps to

:set foldopen-=search

Then, as you search for "foo", the closed folds stay closed; and if
"foo" matches more than once in a given fold, "n" will still move the
the next "foo" outside the fold.  If that is not enough, you can map a
key to do

/foo
:while foldclosed(".") != -1
  call search(@/, 'W')
endwhile

(untested).

     For details on the 'foldopen' option,

:help 'foldopen'

To help find the option you did not know existed,

:options

HTH                                     --Benji Fisher

Reply via email to