Last active
December 13, 2017 08:29
-
-
Save cyansprite/c35aa42d022aa36a0e8fdd4d42d3089a to your computer and use it in GitHub Desktop.
Nice fold text for vim.
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
"Result: | |
"........................................ Text Here ( x lines ) ......................................... | |
function! SuperSexyFoldText() "{{{ | |
let line = ' ' . substitute(getline(v:foldstart), '^\s*"\?\s*\|\s*"\?\s*{{' . '{\d*\s*', '', 'g') . ' ' | |
let lines_count = v:foldend - v:foldstart + 1 | |
let lines_count_text = printf("%s", lines_count) | |
let foldchar = " " | |
let foldtextstart = strpart('' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3) | |
let foldtextend = ' ( ' . repeat(" ", 5 - len(lines_count_text)) . lines_count_text . repeat(" ", 2) . "lines" . ' ) ' | |
let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn | |
return '....' . repeat('.', winwidth('.') / 4) . " " . line . repeat(foldchar, winwidth('.') / 3 - len(line)) . foldtextend . repeat(".", winwidth('.')) | |
endfunction | |
set foldtext=SuperSexyFoldText() | |
" }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment