How I can change cursor color in Vim's color scheme?
Asked Answered
S

3

24

I use this color scheme: Cobalt Colour scheme.

I cannot see the cursor in insert mode.

How I can change the cursor's color?

I think this is the cursor part:

hi CursorLine     guifg=none              guibg=#002943
hi Cursor         guifg=#F8F8F8           guibg=#A7A7A7
hi CursorIM       guifg=#F8F8F8           guibg=#002947"#5F5A60
Saurel answered 3/6, 2011 at 17:23 Comment(0)
P
24

There is quite a lot of information about how to set the insert mode cursor color in the vim documentation

Here is an example from the linked documentation:

highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor+=i:ver100-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10

EDIT:

The i means insert mode, v visual, c command, and n normal

Plural answered 3/6, 2011 at 17:26 Comment(0)
S
37

@GWW is right. But the example above only works for gvim, not vim. You'd better configure in .vimrc as in the same documentation to make it work in xterm, for example:

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
Syzygy answered 15/8, 2014 at 13:53 Comment(2)
"ViM cannot change the color of your cursor; it will always be the color your terminal application decides to make it." unix.stackexchange.com/a/72800/166686Avifauna
@LiviuChircu This is not true. Some terminals like xterm allow it.Libation
P
24

There is quite a lot of information about how to set the insert mode cursor color in the vim documentation

Here is an example from the linked documentation:

highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor+=i:ver100-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10

EDIT:

The i means insert mode, v visual, c command, and n normal

Plural answered 3/6, 2011 at 17:26 Comment(0)
E
0

I came here searching for VIM cursor color in VS code terminal...

"workbench.colorCustomizations": {
    "terminalCursor.foreground": "#ffcc00"  // Change this to your desired color
},
"terminal.integrated.cursorWidth": 3
Emanative answered 31/7, 2024 at 20:46 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.