Vim Configure Line Number Coloring
Solution 1
Try:
help hl-LineNr
I found this through:
help 'number'
which is the way to get help on the 'number'
option, instead of the :number
command.
To actually change the displayed colour:
:highlight LineNr ctermfg=grey
This would change the foreground colour for LineNr on a character terminal to grey. If you are using gVim, you can:
:highlight LineNr guifg=#050505
Solution 2
To change the line numbers permanently add the below to your .vimrc
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
Of course you change the ctermfg
and guifg
to whatever color you want.
Solution 3
In MacVim (with Vim 7.3 at it's core) I've found CursorLineNr
to work:
hi CursorLineNr guifg=#050505
Solution 4
I didn't like the colors provided by the selected color scheme so I modified the color of the line numbers this way:
colorscheme trivial256 " for light background
hi LineNr term=bold cterm=bold ctermfg=2 guifg=Grey guibg=Grey90
Related videos on Youtube
Daniel Spiewak
Updated on July 08, 2022Comments
-
Daniel Spiewak almost 2 years
I'm looking for a way to configure the color used for line numbering (as in:
:set nu
) in Vim. The default on most platforms seems to be yellow (which is also used for some highlighted tokens). I would like to color the line numbers a dim gray; somewhere in the vicinity of#555
. I'm not picky though, any subdued color would be acceptable.-
Jgs pra about 4 yearsIf you want to keep constant your desire preference of color scheme background for permanent in vim and if you want to set numbering to it as well, then it's so easy, go through the link provided below and follow the steps which are so easy to do. jigarpra.blogspot.com/2020/03/…
-
-
devios1 almost 11 yearsDo you happen to have a link to available color names and/or color formats this command supports?
-
nicholsonjf over 10 yearsThanks, this worked for me. Adding 'set number' and 'highlight LineNr ctermfg=grey' on separate lines at the end of my ~/.vimrc file on Ubuntu 12.04 enabled grey line numbers anytime I open a file with vim
-
Ciro Santilli OurBigBook.com almost 10 yearsThis sets the number of the current line only: very useful, but probably not what was required. That was asked at: stackoverflow.com/questions/8247243/…
-
horta almost 9 years7 years later, it appears gVim can handle "grey", but can't handle the number format you describe. :highlight LineNr guifg=grey worked for me.
-
hidden-username over 8 yearsIn order to get the accepted answer to work in my .vimrc I had to follow your advice and add it to the bottom. Can you explain why it has to be at the bottom?
-
qasimalbaqali over 8 years@mikeyprog I don't really know why, since I found the answer online, but I guess so it overrides the default settings. Since it would read the settings from top to bottom.
-
hidden-username over 8 yearsI figured it out. It is actually set in colorscheme command, so you will have to recall it after updating your colorscheme.
-
IC_ over 6 yearsHow can change highlight settings for active
LineNr
? UPD: AnswerCursorLineNr
-
dwanderson over 6 yearsJust ran into same issue as @hidden-username - and just realized it's because I set themes and colors and etc in the middle of my
vimrc
. So... having this at the top, it got overridden. Overwritten. Overrode? -
ecjb over 4 yearsThanks for the answer. The command
:highlight LineNr ctermfg=grey
works for me, however addinghighlight LineNr ctermfg=grey
in the~/.vimrc
file doesn't change anything. Does somebody have an idea? -
Phenyl almost 4 yearsIn my experience, the
highlight
statement has to come aftersyntax on
andcolorscheme
otherwise it's overwritten by the default values of the syntax highlighting. -
trinaldi almost 4 years@ecjb Did you try putting it after your
colorscheme
setting? -
ecjb almost 4 years@Tico thank you for your comment. Yes now it's after the scheme: the current line number is bright and the other are less bright
-
trinaldi almost 4 yearsThat's the idea. You should have another setting for the current line/column set, thus this result.