我在vim中定义了一个函数来适当地缩进折叠。他们看起来像这样:
展开的
this is text
also text
indented text
indented text
not indented text
使用默认功能折叠
this is text
also text
+-- 2 lines: indented text ----------------------------
not indented text
与我的新功能合二为一
this is text
also text
++- 2 lines: indented text ----------------------------
not indented text
唯一的问题是突出显示仍然是这样的:
用我的新功能折叠(用标签突出显示)
this is text
also text
<hi> ++- 2 lines: indented text ----------------------------</hi>
not indented text
我希望突出显示从+开始,而不是在行的开头。我看过VIM手册,但找不到类似的东西。我找到的一个解决办法就是把背景变黑(和我的背景一样)。
highlight Folded ctermbg=black ctermfg=white cterm=bold
但这使得褶皱不那么明显。
我尝试过以下几种变体:
syn keyword Folded lines
syn region Folded ...
但是我认为折叠的选择是不同的,我不能想办法覆盖默认的突出显示。有人能提出建议吗?
顺便说一下,这是我缩进折叠的功能:
set foldmethod=indent
function! MyFoldText()
let lines = 1 + v:foldend - v:foldstart
let ind = indent(v:foldstart)
let spaces = ''
let i = 0
while i < ind
let i = i+1
let spaces = spaces . ' '
endwhile
let linestxt = 'lines'
if lines == 1
linestxt = 'line'
endif
return spaces . '+' . v:folddashes . ' '. lines . ' ' . linestxt . ': ' . getline(v:foldstaendfunction
endfunction
au BufWinEnter,BufRead,BufNewFile * set foldtext=MyFoldText()
顺便说一下,谢谢
njd
帮助我设置这个功能。
注意:我已经交叉发布了这个
on super user
.