3

I use vim via the console.

I have the following line in my vimrc:

highlight LineNr ctermfg=5 

It doesn't do anything, but when I type this in as a command, it correctly changes the line numbers' colors:

:highlight LineNr ctermfg=5

:verbose highlight LineNr gives:

LineNr xxx term=underline ctermfg=11 guifg=Yellow Last set from /usr/share/vim/vim74/colors/elflord.vim 

I've been looking all over for some clue about something I'm missing, but I can't see what it is.

I've also tried using highlight with various other things, like CursorLine, and I can't get it to work with those either.

This is the verbose output for LineNr:

enter image description here

Its odd that the colorscheme is the only thing changing the color-I added the highlight line after the colorscheme in the vimrc.

Martin Tournoij
  • 62,054
  • 25
  • 192
  • 271

1 Answers1

4

If you have anything later in the .vimrc file that changes the same thing as the highlight line, the highlight line will be overridden.

In this case, my "syntax on" line was after the highlight line. Syntax on changes the Line number colors and was blowing away the highlight line changes.

This is what I had before:

highlight LineNr ctermfg=5 
syntax on

This is the correct order to allow the highlight line to override the "syntax on" line:

syntax on
highlight LineNr ctermfg=5