diff --git a/vimrc.functions.vim b/vimrc.functions.vim index daedd9d..e82975d 100644 --- a/vimrc.functions.vim +++ b/vimrc.functions.vim @@ -94,11 +94,19 @@ function! MyFoldText() let l:linecount = v:foldend - v:foldstart - 1 let l:line = getline(v:foldstart) - let l:prefix = '|+' . l:linecount . v:folddashes . '| ' - let l:subexp = '^ \{,' . len(l:prefix) . '}' + let l:postfix = ' +' . l:linecount . ' ' . v:folddashes . '|' + " unicode characters counted as 2 digits in length - TODO find fix + " let l:postfix = ' •••••••••••• +' . l:linecount . ' ' . v:folddashes . '|' - let l:foldtext = substitute(l:line, l:subexp, l:prefix, '') - let l:foldtext = substitute(l:foldtext, '"{\{3}', '', '') + let l:len_line = len(l:line) + let l:len_postfix = len(l:postfix) + + if l:len_line + l:len_postfix <= 80 + let l:padding = ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'[0:79 - l:len_line - l:len_postfix] + let l:foldtext = l:line . l:padding . l:postfix + else + let l:foldtext = l:line[:76 - l:len_postfix] . '...' . l:postfix + endif return l:foldtext endfunction