现在我折叠的线看起来像这样:
+-- 123 lines: doSomeStuff();--------------------------
+-- 345 lines: doSomeOtherStuff();---------------------
Run Code Online (Sandbox Code Playgroud)
我想删除一行之前的所有内容(+ - xxx行:),使其更像Notepad ++/Eclipse visuals方式 - 现在它太难读了,我其实并不在乎我有多少行有一定的折叠:)所以有任何调整折叠线格式的命令吗?
是的,foldtextromainl已经提到的函数返回一个字符串,以一个封闭的折叠显示(换句话说,就是你所看到的).
您可以修改折叠功能以显示您感兴趣的内容.例如,
function! MyFoldText() " {{{
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 3
let foldedlinecount = v:foldend - v:foldstart
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
endfunction " }}}
set foldtext=MyFoldText()
Run Code Online (Sandbox Code Playgroud)
将返回类似于此的内容
" Basic settings --------------------------------------------- {{{... 6 ...
Run Code Online (Sandbox Code Playgroud)
意思是折叠中有6条线(包括具有闭合折叠标记的线)