I have found a related question here:
Automatically set the 'number' option in Vim when entering Ex mode, set 'nonumber' in visual mode

Still I am not sure that I can follow those explanations to achieve what I want.
So here is what I want to achieve:

For normal (and visual) mode, I've set up a color bar, for example here I [ab]use the foldcolumn to indicate that I am in visual mode (see on the left a blue vertical bar):

enter image description here

Now if I go into insert mode I want it to change the color (now the bar is gray as if it is gone):

enter image description here

I want this to set up a strong visual feedback which helps to always see in which mode I am currently.
Sometimes I start to input text when I am in normal or visual mode and this results in running a lot of Vim's commands.

So how can I make that the color changes automatically in run-time when switching from insert to normal mode and back?
Here I use is foldcolumn, but it can be something else with similar effect to this.

VIM 7.4, Windows

2 Answers 2


Use the InsertEnter and InsertLeave autocmd events. For example, say I [ab]used the cursorline setting instead of the foldcolumn:

autocmd InsertEnter * set cursorline
autocmd InsertLeave * set nocursorline

enter image description here enter image description here

So whatever it is you do to change the colour of the foldcolumn (hi FoldColumn ctermbg=blue?), put those as the commands after the autocmd InsertEnter * and autocmd InsertLeave *.

This is easier for the insert mode than other modes, since there are autocmd events for entering and leaving insert mode, but not for normal, visual, etc.


Based on Muru's answer, here is what I made:
In colorscheme file set the default color for foldcolumn:

hi FoldColumn  guifg=#C7C8B8  guibg=#DACBAD  

Then in vimrc file enable foldcolumn (set foldcolumn=2) and add color settings on InsertEnter and InsertLeave events:

autocmd InsertEnter * hi FoldColumn guifg=#C7C8B8 guibg=#E6E5DC
autocmd InsertLeave * hi FoldColumn guifg=fg guibg=#DACBAD

Normal mode:

enter image description here

Insert mode:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.