本文介绍了Vim CursorLine插入模式下的颜色更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更改光标颜色有很好的代码段:

There is good snippet for changing cursor color:

if &term =~ "xterm\\|rxvt"
  " use an orange cursor in insert mode
  let &t_SI = "\<Esc>]12;orange\x7"
  " use a red cursor otherwise
  let &t_EI = "\<Esc>]12;red\x7"
  silent !echo -ne "\033]12;red\007"
  " reset cursor when vim exits
  autocmd VimLeave * silent !echo -ne "\033]112\007"
  " use \003]12;gray\007 for gnome-terminal
endif

我应该如何改变它,而不是光标,CursorLine会改变颜色,例如从深蓝色到蓝色?

How should I alter this that instead of cursor, CursorLine would change color for example from dark blue to blue?

我的完整配置是

推荐答案

你看看

例如,要更改CursorLine,

For example, to change the CursorLine,

:hi CursorLine guifg=red guibg=blue

::help highlight

Reference: :help highlight

要在模式之间切换。

" Enable CursorLine
set cursorline

" Default Colors for CursorLine
highlight  CursorLine ctermbg=Yellow ctermfg=None

" Change Color when entering Insert Mode
autocmd InsertEnter * highlight  CursorLine ctermbg=Green ctermfg=Red

" Revert Color to default when leaving Insert Mode
autocmd InsertLeave * highlight  CursorLine ctermbg=Yellow ctermfg=None

我可能可以混合termcap颜色和autocmd,但IMO,突出更容易长期维护如果使用gVim偶尔)

I may be possible to mix termcap color with autocmd, but IMO, highlight is more easy to maintain in long term (and in case if use gVim occassionally)

这篇关于Vim CursorLine插入模式下的颜色更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-10 23:20