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.

while using vim within tmux I can see that 256 color support is enabled. with $tput colors

However changing the colorscheme in vim while in tmux will change the colorscheme on a per line basis but not the entire background. see screenshot enter image description here

Here is a snippet of the my .vimrc file for example. My original colorscheme is solarized dark and then after running :colorscheme molokai you see what happens.

info

  • gnome-terminal
  • bash

in my ~/.tmux.conf

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

in my ~/.vimrc

    set t_Co=256

in my ~/.bashrc

# ryan
export TERM="xterm-256color"
# ryan
alias tmux="tmux -2"

in my ~/.profile

# ryan 256 color support
if [ -e /usr/share/terminfo/x/xterm-256color ]; then
    export TERM='xterm-256color'
  else
    export TERM='xterm-color'
  fi

Any ideas how I can get a full colorscheme change in vim? Are all my snippets from the files looking good?

share|improve this question
    
What happens if you press control-l in normal mode, or execute the ":redraw" command? –  Heptite Mar 10 '12 at 22:10
    
@Heptite nothing happens still the color change is per line like in the screenshot –  winchendonsprings Mar 10 '12 at 22:19

3 Answers 3

up vote 37 down vote accepted

From the look of your .bashrc and .profile, the shells inside tmux are overriding the 'default-terminal' setting in your tmux conf. Something like this:

  • tmux creates new shell with TERM=screen-256color
  • .bashrc/.profile run, set TERM=xterm-256color
  • vim runs, tries to use incorrect TERM for tmux

you can check this by running

echo $TERM

in a fresh tmux shell.

Tmux is relatively picky about having a terminal set correctly. If you can, set the term value in gnome-terminal's configuration, not in your .bashrc. Failing that, surround those settings with a check for "screen" or "screen-256color" TERM, and don't reset them in that case.

Tmux REALLY wants the terminal set to screen or screen-256color

share|improve this answer
1  
Well you fixed it. I simply commented out anything in my .bashrc and my .profile files that had to do with setting the color to 256. Restarted tmux and vim works with the proper background and 256 colors enabled. Can you tell me where the gnome-terminal config file is? Also when you say tmux wants terminal set to 'scfeen-256color, Do you mean like I have it in my tmux.conf? Thanks –  winchendonsprings Mar 11 '12 at 5:00
    
I don't have a machine with gnome-terminal on it handy to check, but the setting should be somewhere in the GUI, probably under 'profile settings' or something like that. –  bloy Mar 11 '12 at 15:19
3  
Also, yes, let tmux do its own thing to the shells it spawns. Leave the set -g default-terminal "screen-256color" line in your tmux conf. –  bloy Mar 11 '12 at 15:21
1  
All of the above is what I was after (making sure TERM correctly set and not overridden in tmux), and THEN I had to use 'tmux -2' to load tmux up. –  phantomwhale Nov 10 '13 at 23:45

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
2  
this the only thing that finally worked for me! –  Oz123 Jun 7 '13 at 8:07

I've found a better way on this post. You can make an alias of tmux to tmux -2 which will force tmux to assume that the shell is using 256 color terminal.

share|improve this answer

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.