【问题标题】:Setting Vim cursorline colors?设置 Vim 光标线颜色?
【发布时间】:2015-05-23 22:13:08
【问题描述】:

我曾尝试在 SO 和 Google 上查看其他答案,但它们似乎都没有改变我的光标设置。我想要一个黄色背景和白色粗体前景,但无法通过我在网络上看到的设置来获得它。我在 iTerm2 中使用 MacVim mvim。

感谢您的帮助。

【问题讨论】:

  • 不是重复的。 @pertrai1 已经在使用这些选项,如屏幕截图所示。
  • @JeffBridgman - 不,如果你看我的截图,我已经有了可能重复的答案集
  • 很抱歉造成误解。

标签: vim


【解决方案1】:

您很可能对这三个突出显示组感兴趣:CursorCursorColumnCursorLine。这些名称是不言自明的。

例如只改变光标颜色:

:highlight Cursor ctermfg=White ctermbg=Yellow cterm=bold guifg=white guibg=yellow gui=bold

对列光标执行相同的操作:

:highlight CursorColumn ctermfg=White ctermbg=Yellow cterm=bold guifg=white guibg=yellow gui=bold

如果您还需要突出显示当前行,请使用CursorLine

【讨论】:

  • 对不起,我的初学者问这个问题:我将如何在我的 .vimrc 文件中设置它?当我在正常模式下这样做时效果很好,但我希望它一直保持这种状态。感谢您在这件事上对我的容忍。
  • 复制粘贴到.vimrc,不带前导:
  • 这很棒。感谢您帮助解决此问题
  • 感谢您的提示!只是想注意,在我的情况下(Vim 7.4),配置 CursorColumn 突出显示似乎没有任何效果。我不得不设置 ColorColumn 高亮组。
【解决方案2】:

如果您想保持启用,请始终将以下内容放入您的 .vimrc 或 .gvimrc 文件中

光标线

set cursorline
autocmd InsertEnter * highlight CursorLine guibg=#000050 guifg=fg
autocmd InsertLeave * highlight CursorLine guibg=#004000 guifg=fg

用于光标列

set cursorcolumn
autocmd InsertEnter * highlight CursorColumn ctermfg=White ctermbg=Yellow cterm=bold guifg=white guibg=yellow gui=bold
autocmd InsertLeave * highlight CursorColumn ctermfg=Black ctermbg=Yellow cterm=bold guifg=Black guibg=yellow gui=NONE

你可以随意改变颜色

【讨论】:

  • @svlasov 的答案对我不起作用(即使在添加到我的 vimrc 之后)。这个 CursorLine 解决方案很棒。
猜你喜欢
  • 2011-11-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多