Sonique
Sonique

Reputation: 7100

Change cursor color when changing input language with Vim

Today I found the way to change input language in vim by setting in .vimrc set keymap=_mykeymap_ and using Ctrl^.

Is it possible to change cursor color in insert mode when changing input language with Vim?

Upvotes: 1

Views: 860

Answers (3)

Marslo
Marslo

Reputation: 3251

I know how to change the sharp of cursor in insert mode, for example, my setting is:

set guicursor=a:hor1
set guicursor+=i-r-ci-cr-o:hor2-blinkon0

Help file shows:

    n   Normal mode
    v   Visual mode
    ve  Visual mode with 'selection' "exclusive" (same as 'v',
        if not specified)
    o   Operator-pending mode
    i   Insert mode
    r   Replace mode
    c   Command-line Normal (append) mode
    ci  Command-line Insert mode
    cr  Command-line Replace mode
    sm  showmatch in Insert mode
    a   all modes

I don't think the color can be changed in a specified mode (highlight-groups). But you can change the color by using(in all mode):

hi Cursor               guibg=#A6E22E       guifg=#A6E22E     gui=underline

Details can be found from my color configuration

Upvotes: 0

Ves
Ves

Reputation: 1292

For gvim see :help lCursor.

For vim I have no answer, sorry.

Upvotes: 2

miu
miu

Reputation: 1304

In the vim wiki I found this:

It is possible to change the cursor color and style in the terminal if it understands the following escape sequences. Not all terminals support this, but xterm, rxvt and Terminator do. Recent versions of gnome-terminal support the sequence to change color, but not the one to restore the color to the default.

With following in the .vimrc you can change the curser color for the different modes:

if &term =~ "xterm\\|rxvt"
    " use an orange cursor in insert mode
    let &t_SI = "\<Esc>]12;orange\x7"
    " use a red cursor otherwise
    let &t_EI = "\<Esc>]12;red\x7"
    silent !echo -ne "\033]12;red\007"
    " reset cursor when vim exits
    autocmd VimLeave * silent !echo -ne "\033]112\007"
    " use \003]12;gray\007 for gnome-terminal
endif

So you can write a function in which you check the current keymap and switch between the "keymap-cursor-colors".

Upvotes: 0

Related Questions