-
-
Save voyeg3r/4426408 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
" http://vimcasts.org/episodes/writing-a-custom-fold-expression/ | |
function! MarkdownFolds() | |
let thisline = getline(v:lnum) | |
if match(thisline, '^##') >= 0 | |
return ">2" | |
elseif match(thisline, '^#') >= 0 | |
return ">1" | |
else | |
return "=" | |
endif | |
endfunction | |
setlocal foldmethod=expr | |
setlocal foldexpr=MarkdownFolds() | |
function! MarkdownFoldText() | |
let foldsize = (v:foldend-v:foldstart) | |
return getline(v:foldstart).' ('.foldsize.' lines)' | |
endfunction | |
setlocal foldtext=MarkdownFoldText() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment