Environment:
- Fedora 25 (4.9.12-200.fc25.x86_64)
- GNOME Terminal 3.22.1 Using VTE version 0.46.1 +GNUTLS
- VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 22 2017 16:26:11)
- tmux 2.2
I recently started using tmux and have observed that the colors within Vim change depending on whether I'm running inside or outside of tmux. Below are screenshots of Vim outside (left) and inside (right) of tmux while viewing a Git diff:
My TERM variable is
- Outside tmux:
xterm-256color - Inside tmux:
screen-256color
Vim reports these terminal types as expected (via :set term?):
- Outside tmux:
term=xterm-256color - Inside tmux:
term=screen-256color
Vim also reports both instances are running in 256-color mode (via :set t_Co?):
- Outside tmux:
t_Co=256 - Inside tmux:
t_Co=256
There are many similar questions out there regarding getting Vim to run in 256-color mode inside tmux (the best answer I found is here), but I don't think that's my problem given the above information.
I can duplicate the problem outside of tmux if I run Vim with the terminal type set to screen-256color:
$ TERM=screen-256color vim
So that makes me believe there's simply some difference between the xterm-256color and screen-256color terminal capabilities that causes the difference in color. Which leads to the question posed in the title: what specifically in the terminal capabilities causes the Vim colors to be different? I see the differences between running :set termcap inside and outside of tmux, but I'm curious as to which variables actually cause the difference in behavior.
Independent of the previous question, is it possible to have the Vim colors be consistent when running inside or outside of tmux? Some things I've tried include:
- Explicitly setting the default terminal tmux uses in
~/.tmux.confto various values (some against the advice of the tmux FAQ):
set -g default-terminal "screen-256color"
set -g default-terminal "xterm-256color"
set -g default-terminal "screen.xterm-256color"
set -g default-terminal "tmux-256color"
- Starting tmux using
tmux -2.
In all cases, Vim continued to display different colors inside of tmux.


script, startvim, quitvimand then quitscript's shell, and attach the resultingtypescriptfile? Then repeat the same steps withTERM=screen-256color viminstead. – egmont Mar 03 '17 at 11:07xterm-256colorversion (search for "38;5;" in the file), but cannot in thescreen-256color. E.g. wherever there's a\e[38;5;81minxterm-256color(color #81 of the 256-color palette, a middle blue shade),screen-256colorcontains\e[34minstead (the standard blue of the 8-color palette). So the main question is why does vim not use the 256-color palette in case ofTERM=screen-256color. – egmont Mar 03 '17 at 21:04xterm-256colorversion seems to print the screen twice, first with the legacy colors and then with the 256-color palette. Search for e.g. "F1" in the file, you'll find two matches inxterm-256color, the first with\e[34mcolor, the second with\e[38;5;81m. I don't know what's going on here. – egmont Mar 03 '17 at 21:06set -g default-terminal "screen.xterm-256color"in~/.tmux.confand reload the config in tmux (