On Jan 7, 10:16 am, Alexandre Leray <
alexan...@alexandreleray.com>
wrote:
May I suggest my VOoM plugin:
http://www.vim.org/scripts/script.php?script_id=2657
The latest version can outline Markdown
:Voom markdown
It's more powerful than just folding.
But if you must have folding, it should be easy to write a folding
expression.
Here is my attempt, not tested very well:
" folding for Markdown headers, both style
"
http://daringfireball.net/projects/markdown/syntax#header
setl foldmethod=expr
setl foldexpr=Foldexpr_markdown(v:lnum)
func! Foldexpr_markdown(lnum)
let l1 = getline(a:lnum)
" ignore empty lines
if l1 =~ '^\s*$'
return '='
endif
" next line is underline
let l2 = getline(a:lnum+1)
if l2 =~ '^=\+\s*'
return '>1'
elseif l2 =~ '^-\+\s*'
return '>2'
" current line starts with hashes
elseif l1 =~ '^#'
return '>'.matchend(l1, '^#\+')
" keep previous foldlevel
else
return '='
endif
endfunc