Cory Klein
Cory Klein

Reputation: 55690

How do you change the background color of the empty tab space in vim?

In vim, when you create a new tab, the tab bar appears at the top of the screen. On the left are all your tabs, on the far right is an "X" for closing the tabs. In between, there is "empty" space, that on my screen appears white.

I'll admit, I'm very picky about how my terminal looks, and this bright white bar at the top of the screen is distracting. Is it possible to change this color to black, or maybe even gray?

Upvotes: 10

Views: 10973

Answers (6)

Eric Leschinski
Eric Leschinski

Reputation: 153922

vi, set the background color of tabs:

Manually in vim at the vim command terminal:

:syn match Tab "\t"
:hi def Tab ctermbg=darkgreen guibg=#003000

I used the following commands in the vim syntax file to make the changes permanent: (they didn't work in the ~/.vimrc nor the colors/monokai.vim colorscheme files)

syn match Tab "\t"
hi def Tab ctermbg=darkgreen guibg=#003000

I got these results:

enter image description here

Alternatively, There is a syntax highlighting scheme called: "whitespace.vim" that manipulates these background colors. It should just work and you can see it in action by using the command:

:set syntax=whitespace

It has custom colors for the various types of whitespace, you can follow that and see how it works to copy it.

Upvotes: 0

Cory Klein
Cory Klein

Reputation: 55690

TLDR;

For a black tab bar (color 0)

:hi TabLineFill term=bold cterm=bold ctermbg=0

Explanation

Use vim's highlight command to set the attributes you want on the TabLineFill group.

This command will show you a list of all the current groups and their highlight attributes.

:hi

Find TabLineFill, and next to it you will see a preview of how your "tab line" will appear. Also note the attributes on this line.

In order for the color you want to be displayed, the attribute representing your terminal needs to be set to "bold". The two options are "term" and "cterm". If your using vim in a color terminal, then cterm will apply, otherwise term will apply. Set these attributes to bold like this:

:hi TabLineFill term=bold cterm=bold

The attribute "ctermbg" may or may not appear on the TabLineFill line, but it is used to define the color of the terminal background. See the list of cterm-color options by typing:

:help cterm-colors

Choose a color (for unobtrusive, I recommend 0, which is Black), then set the ctermbg attribute to the code for that color:

:hi TabLineFill ctermbg=0

This can all be combined into one single command:

:hi TabLineFill term=bold cterm=bold ctermbg=0

Upvotes: 20

c24w
c24w

Reputation: 7866

If you came here looking to change colours of the tab character, you want this:

:highlight SpecialKey guifg=<color> ctermfg=<color>

Upvotes: 3

John Monroe
John Monroe

Reputation: 21

Since this is the first google result for "vim tab background color":

TabLineFill's ctermbg doesn't do anything for me. Set ctermfg=N where N is the desired background color. Don't set ctermbg, and definitely don't set ctermbg=ctermfg as this creates a white background.

Upvotes: 2

skeept
skeept

Reputation: 12413

Try the following: (you can put that in your .vimrc)

:hi TabLineFill ctermbg=100

you can play with the colors and choose one that you like.

Upvotes: 3

jrdioko
jrdioko

Reputation: 33457

That color is controlled by the current colorscheme. You can use :colorscheme to change schemes and find one you like (that has a better color for that area). You can see some sample schemes here (albeit without a tab bar shown).

Upvotes: 0

Related Questions