Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.