When text is highlighted in vim, for example using the 'em' tag when writing a HTML document, I find that in some color schemes the cursor becomes invisible, making it difficult to correctly place the closing tag. Is there a way to have the cursor change color over highlighted text?
3 Answers
Change color of cursor in gvim
Look at both answers sir, I think you'll have your answer in there....

- 1
- 1

- 865
- 1
- 9
- 18
You'd have to hook into the CursorMoved,CursorMovedI
events and then determine the highlight group under the cursor with synIDattr(synIDtrans(synID(line("."), col("."), 1)), "name")
. If it's one of those diffcult-to-see groups, you can issue a :highlight Cursor ...
command to change it (or else change it back).
But this is rather complicated. Why don't you simply modify the colorscheme and choose a color that is easily recognized under all circumstances?! (The :hi
command lists all colors and helps you choose one.)

- 167,457
- 16
- 250
- 324
-
Thanks for the tip about using :hi command. It's been very useful in customizing my syntax highlighting colors. – Arlen Feb 18 '13 at 20:12
This problem led me down quite a rabbit hole and caused me to learn a lot more about how syntax highlighting works than intended.
I learned that the reason my, supposedly italic, text was highlighted in the first place, is because the Mac terminal doesn't support italics ("Enabling italics in vim syntax highlighting for mac terminal")
I realised, thanks to "Colour colour everywhere! 256 colour-mode for Linux consoles", that due to the color profile I had chosen in Terminal's preferences, my "bright" and "normal" colors showed no difference, and for that reason my color profiles never looked like the screenshots.
And, finally, I solved my cursor getting lost problem by changing the cursor color in the Terminal preferences.
-
Now that you got it working with Terminal, look into using [iTerm2](http://iterm2.com/). It's like Terminal done right. – the Tin Man Feb 19 '13 at 00:20
-
I did download iTerm2 when I was trying to get italics to display but after figuring out a decent work around with terminal I felt that I wasn't really going to make the most of iTerm2's differences with my normal terminal use. I still have it there for the future if I ever advance to command line ninja black belt level. Thanks for the tip. – Arlen Feb 22 '13 at 22:37