UfoRobot
UfoRobot

Reputation: 120

Setting VIM for 256 colors

I've googled it for hours but I can't find a solution. I use raspian, on a raspberry pi and I want to have colorscheems work on it. Default terminal in raspian seems to be set at 8 colors as when I enter

tput colors

I get 8. I'm sure there must be a way to have the term work with 256 colors but I don't know how. Anyway I set tmux in the config file to support 256 colors, so I created a .tmux.conf file in my home directory and have

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

now if I check with tput within tmux I get 256. Anyway I know you can set VIM to force think you support 256 color by adding

set t_Co=256

but this seems to make no actual change. If I run this color test

:runtime syntax/colortest.vim

in normal terminal from raspian I get only 8 different colors. If I do this on tmux I get more but not all of them because some of them (red and lightred for example) still look the same.

Upvotes: 7

Views: 10920

Answers (2)

mirth23
mirth23

Reputation: 387

I was having a similar problem and have solved it with the following setup. .zshrc on my OSX laptop contains:

TERM=xterm-256color

after I ssh into raspbian, tput colors returns 256. On raspbian, I don't have TERM explicitly set (which means it pulls it from ssh), and have the following in .tmux.conf:

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

Then after I do tmux (and I don't even need the -2), tputs colors still reports 256 colors and vim looks right. I am using vanilla solarized with no edits in .vimrc or elsewhere in the vim configs.

Upvotes: 0

J.M. Janzen
J.M. Janzen

Reputation: 702

did you add set t_Co=256 after the line colorscheme <yourColourScheme>? That was a problem I had early on.

Let me know if you're still having trouble, because I managed to solve a similar problem (only I'm using MobaXterm and GNU screen), and wouldn't mind the excuse to dig into this a bit more.

Upvotes: 4

Related Questions