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

  • 1
    The character under the cursor is already highlighted… by the cursor itself. What more do you want? – romainl Jun 23 '13 at 18:21
  • @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 Jun 23 '13 at 18:25
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.

  • 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 Jun 23 '13 at 20:19
  • Tried highlight Cursor guibg=#626262 but does not do anything. – user65971 Jun 23 '13 at 20:51
  • 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 Jun 23 '13 at 20:54
  • 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 Jun 23 '13 at 21:11
  • 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 Jun 24 '13 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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