VIM initial settings: change background color for line number on the left side?

vim
38,236

Solution 1

highlight LineNr ctermfg=grey ctermbg=white

Solution 2

To make the line number column transparent (the same color as the main background) you can try setting this in your .vimrc:

highlight clear LineNr

You can also clear the so-called sign column (used by gitgutter, etc) as well:

highlight clear SignColumn

This way, no matter what color scheme you use, both columns' background will be compatible.

Solution 3

In my _vimrc, here is the setting:

highlight LineNr guibg=grey

or

hi LineNr guibg=grey

I don't need to set fore-color, the default is yellow and it is OK for me.

Solution 4

guibg and guifg are for vims which are not in terminal. For terminal you use ctermfg ctermbg. Usually in GUI vims you have more colors support and you simply want to avoid the background. So I usually use this:

highlight LineNr guibg=NONE
Share:
38,236
David.Chu.ca
Author by

David.Chu.ca

Updated on December 17, 2020

Comments

  • David.Chu.ca
    David.Chu.ca over 3 years

    I use _vimrc to configure my vim 7.2 (windows) default settings. One setting "set number" will display line numbers on the left side. My vim background color is white (I cannot find setting for this. Maybe the default is white. Anyway I accept this setting).

    I would like the background color for line numbers to be Grey or dimmed color. What is the command I can put in my _vimrc to configure this default setting?

  • adam_0
    adam_0 over 7 years
    There's also CursorLineNr instead of LineNr for changing the highlight of the gutter of the line that you're currently on.
  • sushpa
    sushpa about 7 years
    @adam_0 that's cool, turns out that set cursorline is needed as well for highlighting the line and wasn't on by default (at least for me; vim 7.4 on CentOS)
  • sushpa
    sushpa about 7 years
    Actually set cursorline seems meant for "highlighting the entire cursor line" but I seem to need it even to highlight just the gutter.
  • sushpa
    sushpa about 7 years
    Those who use LightLine.vim can get a CursorLineNr highlight that reflects the current mode: hi! link CursorLineNr LightlineLeft_active_0
  • aderchox
    aderchox over 3 years
    this doesn't seem to be useful if the main background is black.