> HI All,
>
> I have a todo list of single line entries.
> I'd like to fold everything away apart from a custom seach, say
>
> :customsearch urgent
>
> would fold away all lines that did not contain urgent.
>
> Has this been done already in some way?
>
> If not, can I search, get the line numbers with results on, and do the
> math to fold away everything else?
>
> Ie, if lines 3 and 8 contain the term,
> mark 1-2, fold
> mark 4-7 fold
> mark 9-end fold
>
> Thanks for your help
> S
>

I have this map setup in my .vimrc, so \z will hide all lines that
don't contain the current search pattern.
    map <silent><leader>z :set foldexpr=getline(v:lnum)!~@/ foldlevel=0
foldcolumn=0 foldmethod=expr<CR>

So in your case, you would search for URGENT in the usual way
   /URGENT
then type \z to hide every line that doesn't have URGENT
   \z

It comes in handy quite often. This is about the only way that
I ever use folding in fact.

Yours,
Noah


Reply via email to