Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
1  
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) –  Stéphane Chazelas Apr 17 '13 at 22:40
    
That's interesting. I didn't know those escape sequences existed. There's information regarding their use with vim here. –  paraxor Apr 17 '13 at 22:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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