I frequently make mode errors while using vim, i.e. I'll start typing text while in Normal mode, or start typing commands while in Insert mode. I understand this goes away with time as vim's quirks seep into your bones, but are there any ways to speed the process?
With gvim, the cursor changes from a block to a vertical bar when going between modes. This at least gives you a little visual feedback.
If you haven't done so already you can display the current mode by using :set showmode
. That'll display -- INSERT --
in the status bar when in insert mode.
I use these autocmd's to highlight the entire line containing the cursor while in insert mode, and not while in normal mode:
if v:version >= 700
autocmd InsertEnter * set cursorline
autocmd InsertLeave * set nocursorline
endif
This provides a little bit more visual feedback about the mode.
Insert mode should only be temporary. Normal mode is, as its name tells, the favourite mode for edition tasks.
Usually, you should spend more time in normal mode, and always hit ESC when you are done inserting something.
Maybe I speak only for myself, but now I have the habit of assuming that I am in normal mode at all times, and I am almost never wrong.
Switch "Esc" and "Caps Lock" keys.
If you accidentally click on "Caps Lock" you will start inputing commands that has nothing to do with what you like to do. It is annoying if you are an experienced user; if you are a beginner it may be a hassle to understand what went wrong.
Every time you need to press the Esc key you have to move you entire hand and to get your pinky finger to touch the Esc key and then replace the entire hand again. Some Vim users will tell you that after a while you get used to doing that and it is not a big deal. I think that argument falls short because you can pretty much get used to mapping any key any where. It is a matter of efficiency.
I believe "Esc" is used very frequently and "Caps Lock" is used seldomly if it is used at all.
So switching the two makes sense as it prevents errors and increases typing speed.
Here is my variant of Ned's Answer. It toggles on window switches (window focus is another modal behavior that provides little visual feedback).
if v:version >= 700
set cursorline cursorcolumn
au WinLeave * set nocursorline nocursorcolumn
au WinEnter * set cursorline cursorcolumn
au InsertEnter * set nocursorline nocursorcolumn
au InsertLeave * set cursorline cursorcolumn
endif
I use it with the zenburn color scheme, and I also turn off cursor blink:
if has("gui_running")
colorscheme zenburn
set guicursor+=a:blinkon0
endif