I want to change the color of the cursor pending on the current mode.
Here is my code so far (.gvimrc).
set gcr=n:blinkon0
set gcr=i:blinkon0
highlight Cursor guifg=white guibg=red
highlight iCursor guifg=white guibg=green
Right now the cursor is gray, nothing changes.
Running highlight Cursor guifg=white guibg=red
manually works, but not the line below.
I want the color green in insert mode and red in every other mode.
Simply putting :set cursorline in your vimrc will highlight the current line in every window and update the highlight as the cursor moves. With the default backslash leader key, typing \c will toggle highlighting on and off. That makes it easy to locate the cursor after scrolling in a large file.
Vim allows the cursor shape, blink rate, and color to be customized, if supported by the underlying system. Depending upon your system, you can make the cursor more prominent using blinking and a distinctive color, or you can make the cursor less distracting by disabling blinking and using a bland color.
I got some help from the vim irc @ freenode.
Here is the solution.
au InsertLeave * hi Cursor guibg=red
au InsertEnter * hi Cursor guibg=green
You have to actually specify the highlight group in the gcr
setting. You also need to put them together, your second "i:" one overrides the first. It also overrides all your defaults, so even combining them doesn't cover the other modes, or the different shapes in modes like operator pending... check out the documentation. Try just altering the default to set your iCursor group on insert mode.
set gcr=n-v:block-Cursor/lCursor,c:block-iCursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-iCursor/lCursor,r-cr:hor20-iCursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175
This is based on the defaults, except i, ci, r, cr, and c (insert, replace, and command line) all use your iCursor
group.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With