Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am having the same problem like the questioner in 256 color support for vim background in tmux.

In my normal terminal with zsh, I have no background color issues in vim, but when I run it inside tmux, I get issues with the background colors.

Apparently, there is a problem with using screen instead of xterm:

Outside Tmux: echo $TERM results in screen
Inside Tmux: echo $TERM results in xterm

In my .zshrc and .tmux.conf I have set

TERM=screen-256color

but it doesn't effect anything. (I also tried TERM=screen)

How can I force tmux to use screen?

EDIT: thanks to htor, I added set -g default-terminal "screen" (also tried set -g default-terminal "screen-256color") in .tmux.conf and in .zshrc export TERM=screen-256color.

Now I get:

Outside Tmux: echo $TERM results in screen-256color
Inside Tmux: echo $TERM results in echoscreen-256color (<- looks a little bit weird with, is the output correct?)

What else can I do to solve the background color issue in vim inside tmux?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

As explained here, disable Background Color Erase (BCE) by clearing the t_ut terminal option (run :set t_ut= in Vim and then press Control+L to refresh the terminal's display) so that color schemes work properly when Vim is used inside tmux and GNU screen.

share|improve this answer
    
thanks sunaku, that was it! –  StandardNerd Mar 7 '13 at 23:12
add comment

To set the default terminal variable for tmux change your .tmux.conf to:

set -g default-terminal "screen"

The shell syntax for setting variables will not work in .tmux.conf. In your .zshrc you should export the value of TERM to make sure all shells inherits this value in your environment:

export TERM=screen-256color
share|improve this answer
    
Thanks htor, with your advice i get now with echo $TERM in- and outside tmux "screen-256color". But the vim background-color issue inside tmux still remains. What else can i do to get rid of this annoying issue (i use tmux and vim a lot)? –  StandardNerd Mar 1 '13 at 9:43
    
@Lennier Have you tried using xterm as TERM value and screen in tmux? Can you post a pastie of your .vimrc in your question? –  Herman Torjussen Mar 1 '13 at 11:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.