2

When I search a text file for a word from within vim, it will highlight all matches for the word by changing their background color -- to olive green on my terminal; your color may vary. I am looking for a way to highlight the background color behind the current cursor position in this way. (This would make the cursor easier for me to see than it is by default.)

By reading the Vim documentation and searching the web, I found plenty of information on highlighting the line the cursor is currently on. But that is not what I'm looking for right now. I am specifically looking for a way to highlight the character at the current cursor position, specifically by changing its background color in the way Vim already does with matches to text searches

How can I do that?

5
  • 1
    Welcome to Vi and Vim! To be honest, I'm not sure why you wouldn't just change your terminal's cursor color at this point...
    – D. Ben Knoble
    Apr 3, 2020 at 18:55
  • 1
    For GUI it's :hi Cursor guibg=#rrggbb. For TUI you really should setup your terminal instead.
    – Matt
    Apr 3, 2020 at 19:10
  • I did make my terminal's cursor as dark as I could. It still wasn't visible enough for me. I need a broader area highlighted. Apr 4, 2020 at 8:49
  • Does this answer your question? Can I use a different color for the selected match than for other matches
    – Tae
    Apr 24, 2020 at 8:06
  • Thanks for the suggestion, Tae, and sorry for the late reply, but no. My problem is that I don't really want to match anything. I just want to highlight the current cursor position. May 1, 2020 at 14:57

1 Answer 1

1

You can turn on search match highlights like this.

:set hlsearch

To turn it off until the next time you search, use this.

:noh

To change highlight to a specific color:

:hi Cursor guibg=#rrggbb
or
:hi Search guibg=<colorname>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.