Saturday, 25 May 2013

vim cursor color change only applied upon movement

vim cursor color change only applied upon movement

In my .vimrc I have the following (based upon a tip on the vim Wikia):
if &term =~ "xterm\\|rxvt"
   " use an red cursor in insert mode
   let &t_SI = "\<Esc>]12;red\x7"
   " use an orange-ish cursor otherwise
   let &t_EI = "\<Esc>]12;\#FFA560\x7"
   silent !echo -ne "\033]12;\#FFA560\007"
   " reset cursor when vim exits
   autocmd VimLeave * silent !echo -ne "\033]112\007"
endif
It is supposed to change the cursor from orange to red when I enter insert mode and change it back when I leave. However this only works if the way I enter insert mode moves the cursor, e.g. 'I' or 'a' but not 'i'. Additionally, if I enter and leave insert mode without having done anything (or moved the cursor), hitting 'escape' will move the cursor back one space, which turns the cursor red, instead of keeping it as orange.
Is there a way to fix this? I'm using xfce4-terminal.

No comments:

Post a Comment