Highlight the character the cursor is on in vim

8,760

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.

Share:
8,760

Related videos on Youtube

user65971
Author by

user65971

Updated on September 18, 2022

Comments

  • user65971
    user65971 over 1 year

    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

    • Admin
      Admin almost 11 years
      The character under the cursor is already highlighted… by the cursor itself. What more do you want?
    • Admin
      Admin almost 11 years
      @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
    user65971 almost 11 years
    Tried highlight Cursor guibg=#626262 but does not do anything.
  • romainl
    romainl almost 11 years
    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.
  • user65971
    user65971 almost 11 years
    I use vim in cygwin. So cygwin is a terminal emulator?Ok I will try it in a linux as soon as I can
  • romainl
    romainl almost 11 years
    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.