The colors you see are, in fine, limited by the "physical" capabilities of your terminal emulator but their number is generally altered by the TERM
environment variable that is used by programs to determine how fancy they can be in their coloring.
In simplistic terms…
when Vim checks your TERM
and sees a value containing 256
, it assumes your terminal emulator is capable of displaying 256 colors and acts accordingly.
when your TERM
is xterm
or screen
(among others), Vim assumes your terminal emulator is only capable of displaying 8 colors and acts accordingly.
Assuming your current TERM
in your local terminal emulator is xterm-256color
and none of the intermediary *rc
sets a specific TERM
:
WHERE TERM COLORS
--------------------------------------------------------------
local xterm-256color 256
local > vim xterm-256color 256
local > remote xterm-256color 256
local > remote > vim xterm-256color 256
local > remote > remote > remote > remote > remote > remote >
> remote > remote > remote > remote xterm-256color 256
local > remote > tmux screen 8
local > remote > tmux > vim screen 8
local > tmux screen 8
local > tmux > vim screen 8
local > tmux > remote screen 8
local > tmux > remote > tmux screen 8
local > tmux > remote > tmux > vim screen 8
Tmux, as a terminal multiplexer, acts as if it was a terminal emulator and changes your TERM
to tmux's default value, screen
, and that new value is what is passed down along the chain.
If you want tmux and fancy colors everywhere, you need to configure each tmux to use a 256 colors-ready TERM
. Put this line in ~/.tmux.conf
on every machine you log in, including yours:
set-option -g default-terminal "screen-256color"