Tmux vim colorscheme background is not showing

tmuxvim

I have installed tmux but now text mode vim colorschemes do not fill the background colour properly. Here is how it looks with colorscheme xoria256 in the normal Ubuntu 14.10 terminal:

enter image description here

And here when I run it in the exact same terminal after tmux:

enter image description here

So as you can see the desktop is showing through anywhere where there is no text in vim. I have a 256 color terminal.

My .tmux.conf:

~ cat .tmux.conf
set -g mode-mouse on
set -g default-terminal "screen-256color"

and I have a 256 colour terminal:

~ tput colors
256

How do I get tmux to work properly with vim 256-colour colorschemes which work fine in the normal terminal?

Best Answer

This happens when TERM isn’t set to the correct screen[-256color] in Vim’s environment, usually by some shell startup script. If that is the case – for example, you have a

TERM=xterm-256color

, either remove it or make sure it checks the original value of TERM before changing it, e.g.

if [[ "$TERM" = xterm ]]; then
    TERM=xterm-256color
fi
Related Question