Vim: 在正常模式下更改配色方案

Vim: Changing colorscheme in normal mode

我想在正常 mode/visual 模式下使用不同的配色方案,在插入模式下切换到默认配色方案。可能吗 ?

谢谢,但这是状态行。我在我的 vimrc 中找到了这样的解决方案:

noremap i :highlight Normal guibg=grey8<cr>i
noremap o :highlight Normal guibg=grey8<cr>o
noremap s :highlight Normal guibg=grey8<cr>s
noremap a :highlight Normal guibg=grey8<cr>a
noremap I :highlight Normal guibg=grey8<cr>I
noremap O :highlight Normal guibg=grey8<cr>O
noremap S :highlight Normal guibg=grey8<cr>S
noremap A :highlight Normal guibg=grey8<cr>A

"You need the next line to change the color back when you hit escape.
inoremap <Esc> <Esc>:highlight Normal guibg=black<cr> 

除了覆盖(内置)命令,您还可以挂接到 InsertEnter / InsertLeave 自动命令:

autocmd InsertLeave * highlight Normal guibg=grey8
autocmd InsertEnter * highlight Normal guibg=black

这也将涵盖更改模式的自定义(插件)映射,并且它避免了 <Esc> 的重新映射,这可能是有问题的。