On 09/01/09 17:22, Philip Rhoades wrote:
> People,
>
> I thought of this when I had a large file and wanted to see only the
> lines that contained the search text, so I could compare them in
> context. Is there a way to automatically use multiple folds for all the
> other text NOT containing the desired search text?
>
> Regards,
>
> Phil
Try the following (untested):
:setlocal foldmethod=expr
:setlocal foldexpr=getline(v:lnum)\ !~\ 'searchtext'
replacing, of course, 'searchtext' by your search text, or by any regexp
you don't want to match. (Charachers which are "special" in a Vim regexp
should be backslash-escaped.) Replace !~ by !~? to force ignore-case
matching, or by !~# to force case-matching. (As shown, your global
'ignorecase' setting will be obeyed.)
To use the latest search pattern, replace 'searchtext' by @/ (like Tim
said).
Best regards,
Tony.
--
Real programmers don't comment their code. It was hard to write, it
should be hard to understand.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---