简体   繁体   English

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

[英]Vim: Changing colorscheme in normal mode

I would like to have a different colorscheme when i'm in normal mode/visual mode and switch to my default colorscheme when i'm in my insertion mode. 当我处于普通模式/可视模式时,我想使用不同的配色方案,而当我处于插入模式时,我要切换到默认的配色方案。 Is it possible ? 可能吗 ?

Instead of overriding the (built-in) commands, you can also hook into the InsertEnter / InsertLeave autocommands: 除了覆盖(内置)命令之外,还可以插入InsertEnter / InsertLeave自动命令:

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

This will also cover custom (plugin) mappings that change modes, and it avoids the remapping of <Esc> , which can be problematic. 这还将涵盖更改模式的自定义(插件)映射,并避免重新映射<Esc> ,这可能会出现问题。

Thanks but it's for the status line. 谢谢,但这是为了状态栏。 I found a solution like this in my vimrc : 我在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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM