I'm using this colorscheme, how can I change the color of the line numbers? I think that the colorscheme will overwrite anything I'll put in .vmrc.
You have a few options to accomplish that.
Actually changing the highlight rules after setting the colorscheme in your Vimrc is not a completely unreasonable approach, since the colorscheme is usually only reloaded if you set the background, so if you tend not to switch from "light" to "dark" or vice-versa, you might be fine...
There are better approaches though.
As recommended in
To customize a color scheme use another name, e.g.
~/.vim/colors/mine.vim, and use
:runtimeto load the original color scheme:
runtime colors/evening.vim hi Statement ctermfg=Blue guifg=Blue
It fails to mention you should also set
g:colors_name, which is what is used to reload the theme after you change the background, so make sure you include this line there:
let g:colors_name = 'mine'
Except instead of "mine" use the name you used for the colorscheme, the name you used for the
colors/*.vim file you created.
Another option is to use an
:autocmd, using the ColorScheme event to load additional highlights right after a colorscheme is loaded.
A simplistic example would be:
augroup colorscheme_override autocmd! autocmd ColorScheme one highlight LineNr ctermfg=Blue guifg=Blue augroup END
This will only override the "one" colorscheme (use a
* for the match to override any colorscheme.)
One advantage of the
autocmd approach is that you don't need a new colorscheme name (but then one disadvantage is that it's harder to pick the unmodified colorscheme.) You don't need to touch
g:colors_name in the
autocmd approach, since the original theme will have taken care of that for you already.
The approaches above are a bit naive in that they're setting colors regardless of whether the background is light or dark. Typically you would want to check for that to decide on it. Use a block similar to:
if &background ==# 'light' highlight LineNr ctermfg=DarkBlue guifg=DarkBlue else highlight LineNr ctermfg=LightBlue guifg=LightBlue endif
If using a ColorScheme
autocmd, you probably want to call a function from the
autocmd and then add all your extra logic there for the overrides, including the blocks for light and dark backgrounds.