Vim中折叠和子折叠的不同颜色

ThG*_*ThG 11 vim folding

是否可以为折叠和子折叠设置不同的颜色,例如:

  • 折叠级别1的灰色背景上的蓝色前景(默认)
  • 黑暗的黄色背景上的黑色前景折叠级别2
  • 等...(虽然进一步下降似乎有点过分)

Ben*_*oit 6

来自 vim 文档:

COLORS                          *fold-colors*

The colors of a closed fold are set with the Folded group |hl-Folded|.  The
colors of the fold column are set with the FoldColumn group |hl-FoldColumn|.
Example to set the colors: >

        :highlight Folded guibg=grey guifg=blue
        :highlight FoldColumn guibg=darkgrey guifg=white
Run Code Online (Sandbox Code Playgroud)

所以你不能轻易做到这一点。我能给你的最好的建议是设置状态栏以显示当前的折叠级别(如果可能)。


Fab*_*ien 5

这取决于您使用的是 Gui Vim 版本还是文本版本。从我这边(文本版本)我已经在我的 .vimrc 中设置了

hi Folded ctermfg=Black
hi Folded ctermbg=DarkGrey
Run Code Online (Sandbox Code Playgroud)

  • 对于那些对 rc 文件迂腐的人来说,“hi”是“highlight”的缩写。我发现当我不可避免地长时间不回到我的 vimrc 时,使用长格式效果更好。 (5认同)