1) I have in my .vimrc a fold expr (cf. the third example under the :help fold-expr section) which makes a fold out of paragraphs separated by blank lines :
set foldmethod=expr
set foldexpr=getline(v:lnum)=~'^\\s*$'&&getline(v:lnum+1)=~'\\S'?'<1':1
Most of my files are files with paragraphs (to begin with my .vimrc)
2) But I have two or three text files which are simply lists with no paragraphs and I would like to be able to fold everything except for matches to my search. I found in Vim Wikia (Tip 282) the following "Simple Folding" (at the bottom of the Tip's page) which I would like to implement :
:set foldexpr=getline(v:lnum)!~@/
:nnoremap <F8> :set foldmethod=expr<CR><Bar>zM
How can I have both of them peacefully coexist in my .vimrc ?
- Is setlocal (for the second foldexpr) the solution ? Tried, failed…
- Is it possible to have a fold expression (the second one) apply only to two files (file1.txt, file2.txt) ?
- Is it possible to merge the 2 foldexpr in one ?
Thanks for your help