Skip to content

Instantly share code, notes, and snippets.

@thinca
Created March 1, 2010 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinca/318544 to your computer and use it in GitHub Desktop.
Save thinca/318544 to your computer and use it in GitHub Desktop.
setlocal foldmethod=expr
setlocal foldexpr=MarkdownFold()
function! MarkdownFold()
let head = s:head(v:lnum)
if head
return head
elseif v:lnum != line('$') && getline(v:lnum + 1) =~ '^#'
return '<' . s:head(v:lnum + 1)
endif
return '='
endfunction
function! s:head(lnum)
return strlen(matchstr(getline(a:lnum), '^#*'))
endfunction
@thinca
Copy link
Author

thinca commented Oct 4, 2010

This script has been moved to http://github.com/thinca/vim-ft-markdown_fold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment