You are not logged in.

#1 2013-06-18 22:04:05

Trusted User (TU)
From: England
Registered: 2008-03-18
Posts: 115

Cannot get vim to display 256 colors


I want to try out a 256 color scheme in vim but I cannot get any to work. At best I think my vim is capable of only 16 colors which I tested with:

:runtime syntax/colortest.vim

I have tried using urxvt and xterm and I get the same result. I have tried setting my $TERM to one of:


After reading several tutorials and suggestions, "tput colors" returns 256 and running displays the colors correctly in the terminal. In vim, ":set t_Co?" returns 256 (I do not specify that in my vimrc) and ":echo $TERM" shows $TERM is set as expected (one of the above).

I created a new user to test with and that has the same problem. I asked on #vim but they were stumped.

Is it really that hard to get vim to display a 256 color scheme? Any help appreciated, thanks.

PGP key: F40D2072
Key fingerprint: 8742 F753 5E7B 394A 1B04  8163 332C 9C40 F40D 2072


#2 2013-06-19 03:27:32

rockin turtle
From: Montana, USA
Registered: 2009-10-22
Posts: 218

Re: Cannot get vim to display 256 colors

Getting vim to work with colors from a terminal is a little tricky. Many colorschemes are written for gvim only and won't work correctly from a terminal. … a_terminal


#3 2013-06-19 04:59:06

From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: Cannot get vim to display 256 colors

Have you set vim's terminal options with ':set t_Co=256' ?  To avoid setting vim to 256 colors in a linux terminal, I have this in my .vimrc:

" Use 256 color when using xterm or urxvt.
" A $WINDOWID only exists when using X.
if exists($WINDOWID)
    set t_Co=256
syntax on        " Add syntax highlighting.

I have $TERM set in my X resources files with:

! Equivalent to 'xterm -tn xterm-256color' at the command line.
xterm*termName: xterm-256color

Urxvt automatically starts with $TERM set as 'rxvt-unicode-256color' with my setup.  I haven't explicitly set it.

Screen, from an xterm, won't display 256 colors in vim unless I start screen with:

$ screen -T xterm-256color

I'm not sure what the trick is to get vim with 256 colors when using screen from urxvt.


Board footer

Powered by FluxBB