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 ?
Asked
Active
Viewed 301 times
1
-
This can help you http://stackoverflow.com/questions/14013294/vim-how-to-detect-the-mode-in-which-the-user-is-in-for-statusline – Ôrel Jun 08 '15 at 02:24
2 Answers
3
Instead of overriding the (built-in) commands, you can also hook into the InsertEnter
/ InsertLeave
autocommands:
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.

Ingo Karkat
- 167,457
- 16
- 250
- 324
0
Thanks but it's for the status line. I found a solution like this in my 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>

espace3d
- 23
- 10