I want to fold sections in a document. Each new section should define a top-level fold instead of a nested fold. I want to use a single delimiter to define a fold. Consider an example document:
>>> first fold
also in first fold
>>> second fold
still in second fold
I want to fold like this:
+----2 lines: first fold
+----2 lines: second fold
Using foldnestmax=0 does not affect foldmethod=marker, it only works on indent and syntax fold methods. Using foldmarker=>>>,>>> does not work, it creates nested folds. The only option I have found is to use fold numbers, e.g. >>>1 first fold, but I'd like to avoid that. Is that possible?
" vim:set foldmethod=expr foldexpr=getline(v\:lnum)=~\'>>>\'?\'>1\'\:\'=\' foldlevel=0 foldclose= :– John Freeman Mar 03 '15 at 15:32=~#is for case-sensitive matching; it doesn't matter here (but I like to be explicit). You could define a:functionin your vimrc and reference that in the modeline; would save you from the escaping (and repetition). – Ingo Karkat Mar 03 '15 at 15:38