我在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。