Created
March 1, 2010 16:52
-
-
Save thinca/318544 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script has been moved to http://github.com/thinca/vim-ft-markdown_fold.