vimwiki's help docs, and this answer, both explain how
g:vimwiki_folding='list' in my vimrc enables list folding for vimwiki files. This lets me use vim's native folding methods on vimwiki lists (e.g.,
zM to fold sublist items,
zr to open folds, etc.)
But a few lines down in the docs, I've followed instructions to enable blank lines between folded sections (which I prefer for readability), which required me to add the following to my vimrc:
let g:vimwiki_folding='custom' function! VimwikiFoldLevelCustom(lnum) let pounds = strlen(matchstr(getline(a:lnum), '^#\+')) if (pounds) return '>' . pounds " start a fold level endif if getline(a:lnum) =~? '\v^\s*$' if (strlen(matchstr(getline(a:lnum + 1), '^#\+'))) return '-1' " don't fold last blank line before header endif endif return '=' " return previous fold level endfunction augroup VimrcAuGroup autocmd! autocmd FileType vimwiki setlocal foldmethod=expr | \ setlocal foldenable | set foldexpr=VimwikiFoldLevelCustom(v:lnum) augroup END
Of course, the line
let g:vimwiki_folding='custom' overwrites the earlier setting of
'list', so I lose list folding.
What can I do to keep my custom folding, but also re-enable list folding? Is there an edit I can make to the
VimwikiFoldLevelCustom function to achieve this?