I have text files which are simply lists with no paragraphs.
When I want to focus on an item, I am able to fold everything except for matches to my search, thanks to Vim Wikia (Tip 282 :"Simple Folding") :
:set foldexpr=getline(v:lnum)!~@/
:nnoremap <F8> :set foldmethod=expr<CR><Bar>zM
This proves to be useful : thus I can see very clearly the items I am looking for : they appear in white on a black background, whereas the folds are darkgrey (ctermfg) on grey (ctermbg).
But there is a - minor - glitch. It may happen (and, in fact, it often happens) that a single line not containing the pattern remains between two lines containing the pattern, eg :
1 pattern
2 not pattern
3 not pattern
4 pattern
5 not pattern
6 pattern
Simple foldind will fold away lines 2 and 3, not line 5.
How should I proceed to hide away this single line ?
Is there a way to fold zero line (this reminds me of the koan about one hand clapping…) ? I suppose that this is not possible.
So, is there a way to simply hide the line (e.g. with the same highlighting as the folds) with a function ?