10

I want to make the cursor and selected text easier to read in vim (white background, black foreground), so i've done

hi Visual guibg=white guifg=black gui=NONE ctermfg=black ctermbg=white cterm=reverse
hi Cursor guibg=white guifg=black gui=NONE ctermfg=black ctermbg=white cterm=reverse

which gives me exactly what i want on MacVim. On the vim terminal, however, it defaults to the terminal preferences, which is very difficult to read and find...how can i override the terminal defaults?

Edit: to say that the hi Visual like works perfectly. It's the hi Cursor that doesn't.

Jose187
  • 449
  • 1
  • 7
  • 15

2 Answers2

10

You can't change the cursor colour programatically (i.e. just do it for vim), but you can change it in Terminal>Preferences>Profiles>Text>Cursor (see image), which may solve your issue.

I find a bright green cursor makes a big difference for visibility!

EDIT: This is mentioned in the comments, but I missed that the first time so I think it deserves its own answer.

Terminal settings

gib
  • 1,951
  • 1
  • 21
  • 24
9

I am not a Mac user, but I don't believe this is possible. The cursor colour in console Vim is inherited from the terminal application, and can't be modified.* You could try changing the cursor colour in the terminal preferences.

*Disclaimer: this is certainly true of the Windows command prompt, which I am forced to use at work. It wouldn't surprise me if other Unix-like shells were more flexible.

ib.
  • 27,830
  • 11
  • 80
  • 100
Prince Goulash
  • 15,295
  • 2
  • 46
  • 47
  • 3
    Some terminal emulators support control codes for altering the cursor color, but not Mac OS X Terminal (at least as of 10.8). – Chris Page Aug 15 '12 at 03:43
  • 2
    Verified this is true of terminal in OSX as of 10.8.2. I wasted some time trying to change the cursor shape to a vertical bar 25% width in insert mode. – Sixto Saez Oct 10 '12 at 15:44
  • 9
    Changing the cursor color is now possible in OS X Mavericks (10.9). Just go to the settings, edit your theme and use the new "Cursor" color picker. – Guillaume Algis Oct 31 '13 at 08:54
  • 2
    can it be programmatically set? or can it only be set in the settings panel? it would be supercool if i could program the cursor background/foreground in vim for terminal.app –  Aug 05 '14 at 01:33
  • Up MacOS 10.12.1, Terminal.app can not do this. You can set the style via an escape sequence, but not the color. – Danny Dulai Dec 17 '16 at 18:33
  • 1
    This is still true in macOS Catalina, super annoying! – Luciano Jul 27 '20 at 04:43