I am trying to highlight the current line as well as the cursor position in Vim. Here's my .vimrc:

set cursorline
hi CursorLine ctermbg=8 ctermfg=15 "8 = dark gray, 15 = white
hi Cursor ctermbg=15 ctermfg=8

The problem I'm experiencing is that the current line background color covers up the cursor background color, so it looks like this:

The current line is highlighted but the cursor is not.

I can obviously tell where the cursor is because the foreground color is almost black, but when the cursor is on a space or at the beginning/end of a line I have no clue where it is unless I move it.

The cursor is at the end of the line, though you'd never know it.

What am I doing wrong here?

2 Answers 2


You have to change the color of your cursor line to a color other than the color of your cursor. If you're in a terminal emulator like st or rxvt, Vim cannot change the color of your cursor; it will always be the color your terminal application decides to make it. Only the graphical version of Vim is able to change the color of your cursor.

You can change your cursor color through your terminal configuration though.

Some ~/.Xdefaults / ~/.Xresources examples:

XTerm*cursorColor: #FFFFFF
URxvt.cursorColor: white

You could also use the Vim command :set cursorcolumn to put your cursor in crosshairs.

  • 5
    vim could change the cursor colour, on those terminals like xterm that allow you to change it dynamically (printf '\033]12;#f50\7' for instance). You can also change it to a blinking block or underline (\e[1 q or \e[3 q) Commented Apr 17, 2013 at 22:40
  • 1
    That's interesting. I didn't know those escape sequences existed. There's information regarding their use with vim here.
    – user26112
    Commented Apr 17, 2013 at 22:45

If you do not want to enter the command each time you start Vim, you have to put the commands in your .vimrc file.

whereis vim    
*#type in your linux terminal* 

(you'll have a different location, but your color scheme will be here /usr/share/vim/vim74/colors/.

You can list the existing color schemes with

ls /usr/share/vim/vim74/colors/    

try different color schemes from the listed

:colorscheme desert
:colorscheme delek

The following command in Vim activates a vertical line at the cursor's location.

set cursorcolumn 
hi CursorColumn ctermbg=8

to toggle (with the exclamation mark, works with all set-command)

set cursorcolumn!

for example:

set cursorline
set cursorline!

hi CursorLine ctermbg=235
*#defines a gray colour for the horizontal line*

Here is a table with xterm colours: link

Use a number by defining ctermbg=... (... = color number from the table) You can also try ctermfg=..., but it's not worth using it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .