I am using gnome-terminal with bash.

When I set xterm-256color for $TERM and in .tmux.conf most of the things work but when I try to change the colorscheme of vim the things mess up.

When I set screen-256color for $TERM and in .tmux.conf the colors work ok but most of the keys go mad. I've tried some of the suggestions from the last link but when I ssh the arrows crash even on the command line..

So how to configure tmux?

2 Answers 2


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.

This way, you can keep your TERM value as xterm-256color for proper key detection while also getting proper Vim color scheme rendering too! :-)

  • 2
    We noticed you recently posted the same answers to multiple questions. If the questions happen to be about the same issue, please flag them for our attention to have them closed as duplicates. In general, please don't post the (verbatim) same content as an answer to multiple questions. Thanks.
    – slhck
    Mar 7, 2013 at 19:12

Because you didn't state exactly what problems you had with keys here is a shot in the dark.

These lines in my ~/.vimrc make the arrow keys work properly in Vim in tmux:

nnoremap <Esc>A <up>
nnoremap <Esc>B <down>
nnoremap <Esc>C <right>
nnoremap <Esc>D <left>
inoremap <Esc>A <up>
inoremap <Esc>B <down>
inoremap <Esc>C <right>
inoremap <Esc>D <left>
  • The problem is just like the one described in the link - when I use CTRL + arrow, it deletes some lines. And this mappings did not help.. Also I am not very sure that I should use screen-256color (although I read somewhere that tmux should be used with it). The idea is that if I use xterm-256color, then when I ssh I don't have to do any config.
    – bliof
    Nov 21, 2012 at 12:21
  • It's described in an external link, not in your question. You shouldn't expect anybody to go play pokemon with the pieces of information necessary to understand your problem. Anyway, What is the output of :echo &term in vim without anything $TERM-related in your config files? Could you try setting your $TERM as xterm-256color and add this set-window-option -g xterm-keys on to your .tmux.conf?
    – romainl
    Nov 21, 2012 at 12:42
  • vim without tmux - xterm; vim with tmux - xterm-256color; Setting the $TERM to xterm-256color and adding the command that you said got me to the problem with the colorschemes.
    – bliof
    Nov 21, 2012 at 12:58
  • I totally forgot that my .bashrc at home has got a fairly involved piece of code to deal with wrong colors. I'll dig it up when I'm back home. IIRC, it's a 20+ lines conditional block that is meant to set $TERM and a few other settings correctly.
    – romainl
    Nov 21, 2012 at 13:06
  • This is the piece of code in question. Don't know if it is of any use to you.
    – romainl
    Nov 21, 2012 at 18:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .