I connect to a server via SSH from xfce4-terminal.

When I open vim outside of tmux, colors in vim are very bright (which is good): bright colors in vim

When I start tmux with default config, and open vim from there, it displays normal colors (t_Co=8):
normal colors in vim

However, if I set default-terminal to "whatever-256colors" (or start tmux with -2) , and start vim from tmux, some colors are very dim:
dim colors in vim

Vim does recognize that this is a 256-color terminal, since t_Co gets set to 256.

I found out that entering :set background=dark in vim fixes the colorscheme, however, that isn't the proper fix, because this only inverses the problem (i.e. it causes vim to use bright colors with a terminal with light background).

How do I make vim correctly determine background color while in tmux, without setting it explicitly?

Ouside of tmux, $TERM is equal to xterm-256color.

.tmux.conf contains:

set -g default-terminal "screen-256color"

Inside tmux, $TERM is screen-256color. Changing terminal type to xterm-256color didn't help.

  • Setting TERM to WHATEVER-256colors, as I already stated, doesn't help, -2 flag doesn't help. Setting default-terminal in .tmux.conf doesn't help. – user3469976 Dec 11 '17 at 11:52
  • @IporSircer the problem is that vim displays WRONG colors when tmux is configured to support 256 colors. – user3469976 Dec 11 '17 at 12:00
  • What's your $TERM in the first case, that is, outside of tmux? – egmont Dec 11 '17 at 13:10
  • @egmont It is xterm-256color. – user3469976 Dec 11 '17 at 13:13
  • @Christopher yep – user3469976 Dec 11 '17 at 13:41

Browse other questions tagged or ask your own question.