I installed tmux in iTerm 2.(Build 3.0.13) When I execute vim in tmux, syntax highlighting looks like this.

no syntax highlighting

But outside tmux, syntax highlighting looks fine.

ordinary syntax highlighting

My $TERM inside and outside tmux is xterm-256color. I also added

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

in .tmux.conf and added this

set t_Co=256
set t_AB=m
set t_AF=m
if &term =~ '256color'
    set t_ut=

in .vimrc.

I also tried tmux -2 command and read these questions.

lose vim colorscheme in tmux mode

Incorrect colors with vim in iTerm2 using Solarized

Is this a problem of tmux, vim, or my configuration?


My .vimrc in GitHub Gist


  • What will happen when you start your tmux with -2 option: tmux -2. Preferably when there are no sessions in tmux.
    – grodzik
    Dec 22, 2016 at 14:17
  • I used tmux -2, but the problem is same.
    – sohnryang
    Dec 22, 2016 at 14:17
  • Could you share whole .vimrc?
    – grodzik
    Dec 22, 2016 at 18:25
  • 1
    @sohnryang what part of "maybe you shouldn't" do you not understand?
    – muru
    Dec 26, 2016 at 10:02
  • 1
    Try following these steps. You have a whole lot of plugins so perhaps one of those is interfering. Dec 31, 2016 at 3:49

3 Answers 3


Well, I solved the problem by myself.

as @Carpetsmoker♦ commented, I started to suspect that my .vimrc is a problem. I read this question and started vim with this command inside tmux.

vim -u NONE -U NONE -N ~/.vimrc

After starting vim with command above, I ran this command inside vim.

:syn on
:colorscheme solarized8_dark

These highlighted my .vimrc file. So, I started to debug my .vimrc.

Long story short, set termguicolors was the problem. If I ran vim with set termguicolors commented in .vimrc, I could see corrected syntax highlighting in tmux.

  • I had the same issue. would be great to get termguicolors working on tmux though
    – filype
    Jan 26, 2017 at 11:29
  • thank you! this fixed it, I spent quite a while trying to figure this out Mar 18, 2021 at 21:27

From the vim manual: :h termguicolors recommends reading :h xterm-true-color, also see :h $TERM

Sometimes setting 'termguicolors' is not enough and one has to set the |t_8f|
and |t_8b| options explicitly.  [ ... these are]  only set [to some default] when `$TERM` is `xterm`.

I use a condition similar to the below: (nvim recommends not using &term but rather $TERM )

if $TERM =~# '256color' && ( $TERM =~# '^screen'  || $TERM =~# '^tmux' )
    let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
    let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
    set termguicolors
  • This one worked for me on NVim. Running on Arch and Fish shell
    – olleh
    Apr 29, 2020 at 10:27

I actually made it work just fine with termguicolors. This is what I did 1. in my ~/.bash_profile i put this:

export TERM=xterm-256color

and inside my ~/.vimrc I had this

syntax enable
colorscheme Spacegray

set termguicolors

and it worked perfectly! reference

  • :syn on : colorscheme Spacegray : set termguicolors
    – abbood
    May 9, 2018 at 15:33
  • In my case, it worked well without set termguicolors. Thank you, anyway! Apr 19, 2020 at 5:24
  • Adding the export fixed it in my case, nice work! Mar 18, 2021 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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