When I try to open a file using vim inside tmux the whole window freezes. I have to kill the window with C-a &.

Here are my ~/.vimrc settings:

:set autoindent
:set ts=4
:set number
:set shiftwidth=4
:set showmode
:filetype on
:filetype plugin on
:syntax enable
:set mouse=a

and ~/.tmux.conf

# I like Ctrl-a as the default hotkey
unbind C-b
set-option -g prefix C-a

# Split window using | and -
unbind %
bind | split-window -h
bind - split-window -v

# Set status bar
set -g status-bg black
set -g status-fg white
set -g status-left ‘#[fg=green]#H’

# Highlight active window
set-window-option -g window-status-current-bg red

# Makes window numbering start from 1, instead of 0
set -g base-index 1

I am facing the problem in RHEL. However the same config works fine in my Mac. I guess, things were working fine till my RHEL box got restarted and I tried to recover a file in from vi swap file.

Any ideas on how to fix this?

[edit]: I tried ssh to other box inside tmux and running vi there. Works fine in remote box !

[added later] Following the suggestion of @jasonwryan, I added the line set -g default-terminal screen-256color at the end of tmux.conf. That prevented programs like less from working.

echo $TERM inside tmux is "screen" and outside tmux is "xterm".

Searching for $TERM led me to https://wiki.archlinux.org/index.php/Tmux, from where I added the line set -g default-terminal "screen-256color" as the first line of tmux.conf. This made the $TERM inside tmux to "screen-256color". But now when I start vi inside tmux, it displays the following error:

E558: Terminal entry not found in terminfo
'screen-256color' not known. Available builtin terminals are:
defaulting to 'ansi'

Looks like I have solved the issue. Just added set -g default-terminal xterm as the first line of my ~/.tmux.conf and it worked !

  • 1
    It may not be related, but you should set the correct TERM in tmux with set -g default-terminal screen-256color
    – jasonwryan
    Commented May 18, 2012 at 7:11
  • 3
    Can you update your question with your $TERM in and outside tmux?
    – jasonwryan
    Commented May 18, 2012 at 8:48
  • 1
    Outside of tmux, execute 'echo $TERM'. Inside of a tmux session, execute 'echo $TERM'.
    – George M
    Commented May 18, 2012 at 11:16
  • 1
    You should only set your tmux TERM to a screen derivative: see the FAQ: it will cause you issues down the track otherwise...
    – jasonwryan
    Commented May 21, 2012 at 7:08
  • 1
    You should write your own answer and post it, with that in it, and then accept it (it's perfectly acceptable to do so). Commented May 21, 2012 at 7:25

2 Answers 2


I solved the issue by adding the line

set -g default-terminal xterm

as the first line of my ~/.tmux.conf and it worked fine.

However as @jasonwryan has pointed out, the TMUX FAQ clearly states that:

Most display problems are due to incorrect TERM! Before reporting problems make SURE that TERM settings are correct inside and outside tmux.

Inside tmux TERM must be "screen" or similar (such as "screen-256color"). Outside, it must match your terminal ...

I only post this answer as it actually solved my problem. please feel free to add your alternative solutions.


I just ran into the same problem on an old CentOS box I had to work on. For me setting TERM in tmux to xterm caused other strange issues to pop up. However, I was able to fix it by commenting out set mouse=a in my .vimrc c.f. https://lists.gnu.org/archive/html/screen-users/2005-04/msg00039.html

Apparently adding set ttymouse=xterm2 to your .vimrc may also do the trick.

For anyone else running into similar issues I recommend temporarily moving your .vimrc to see if something in there is the cause.

You must log in to answer this question.

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