Highlight the character the cursor is on in vim

3

How can I highlight the cursor in vim? I am interested in highlighting only the letter that the cursor is in.
Using:

set cursorcolumn  
highlight CursorColumn guibg=lightblue ctermbg=lightgray  

Highlights the entire column and I want only the character that the cursor is on to be highlighted

user65971

Posted 2013-06-23T18:04:01.093

Reputation: 317

1The character under the cursor is already highlighted… by the cursor itself. What more do you want? – romainl – 2013-06-23T18:21:55.460

@romainl:I used the cursorline and the line is highlighted in a lightgray color.If I add the above snippet I get a cross.I want the instead the character under the cursor to get this color – user65971 – 2013-06-23T18:25:54.360

Answers

2

CursorColumn is irrelevant, what you need to define is Cursor, preferably with a background color different from CursorLines's background color.

Supposing your Cursorline has a dark gray background:

highlight CursorLine guibg=#303030

You can have a slightly lighter Cursor:

highlight Cursor guibg=#626262

Vim's behavior may be different in a terminal emulator, though. As an example, whatever I do with cterm or ctermbg, I can't make it look how I want in Gnome terminal: it's always in reverse video. Which makes it perfectly outstanding, actually. In rxvt-unicode, the background color of the cursor is always the one defined in ~/.Xdefaults, which can be whatever you want.

romainl

Posted 2013-06-23T18:04:01.093

Reputation: 19 227

I pasted the highlight CursorLine guibg=#303030 (after I commented my definitions) and all I see is that the current line is underlined. Additionally in your answer you don't define a Cursor although you mention that this is what I need. – user65971 – 2013-06-23T20:19:49.887

Tried highlight Cursor guibg=#626262 but does not do anything. – user65971 – 2013-06-23T20:51:29.200

That was a typo. Fixed. Do you use Vim in a terminal? GVim? That line in my answer will only work in GVim. I explained in the last paragraph that you won't get the result you want in a terminal emulator. – romainl – 2013-06-23T20:54:36.263

I use vim in cygwin. So cygwin is a terminal emulator?Ok I will try it in a linux as soon as I can – user65971 – 2013-06-23T21:11:37.880

I don't know Cygwin. You use GVim if you have menus like "Tools" or "Syntax" or if the output of :echo has('gui_running') is 1. If you use Vim in a terminal emulator you must configure that terminal emulator so that it uses a color that works for you. – romainl – 2013-06-24T07:11:11.267