I have text files that are just paragraphless lists. When I want to focus on an element, I can dump everything but matches into my search, thanks to Vim Wikia (Tip 282: โSimple foldโ):
:set foldexpr=getline(v:lnum)!~@/
:nnoremap <F8> :set foldmethod=expr<CR><Bar>zM
This turns out to be useful: in this way, I can very clearly see the objects I'm looking for: they appear in white on a black background, while the folds are dark gray (ctermfg) on โโgray (ctermbg).
But there is - a minor - glitch. It can happen (and, in fact, it often happens) that one line that does not contain a pattern stays between two lines that contain a pattern, for example:
1 pattern
2 not pattern
3 not pattern
4 pattern
5 not pattern
6 pattern
A simple fold will fold lines 2 and 3, not line 5.
How should I hide this single line?
( , ...)? , .
, (, , ) ?