开发者

Change color of cursor in gvim

开发者 https://www.devze.com 2023-03-08 17:59 出处:网络
I want to change the c开发者_JAVA百科olor of the cursor pending on the current mode. Here is my code so far (.gvimrc).

I want to change the c开发者_JAVA百科olor 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号