There is good snippet for changing cursor color:
if &term =~ \"xterm\\\\|rxvt\"
\" use an orange cursor in insert mode
let &t_SI = \"\\]12
This is pretty straightforward, put the following in your .vimrc or custom colorscheme file.
set cursorline
autocmd InsertEnter * highlight CursorLine guifg=white guibg=blue ctermfg=white ctermbg=blue
autocmd InsertLeave * highlight CursorLine guifg=white guibg=darkblue ctermfg=white ctermbg=darkblue
For more information see:
N.B: You can use the same method to change the colour of the cursor without all of those if
-statements and escape-sequences (and this will also work in GVim).