Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm often doing the same mistake in vim:

  • I forget whether I'm in insert or command mode, then I type in, I get random commands or I modify/delete code, and I have to undo. I do this mistake really too often.

I was thinking of using the :colorscheme my_color_file to switch between two color schemes depending if I'm in insert mode or not.

Basically, the command_color_file.vim has a red signature(keywords, tabs) for command mode, while the insert_color_file.vim has a green signature.

However I don't find how to perform the :colorscheme call any time I enter one mode or another.

Any idea if it is possible to do that?

share|improve this question
up vote 8 down vote accepted

I haven't tested, but try something like this:

:autocmd InsertEnter * :colorscheme my_color_file_insert
:autocmd InsertLeave * :colorscheme my_color_file_command

This page, about Event-driven scripting in Vim seems to have a good description of how to do it

share|improve this answer
it works perfectly ! – Stephane Rolland Feb 23 '13 at 2:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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