How to get 256 colors with GNU screen and vim

If you're anything like me -- and let's hope you're not -- you've wanted to get vim to look pretty.

What, why?

Ubuntu, for some reason, ships with GNU screen and vim not configured to take advantage of 256 color terminals. I'm sure it has something to do with the massive number of users whose monitors cannot display more than 16.

Say you really like one of the color schemes for vim displayed over at the vim color scheme test, but when you download and install it, it looks terrible! You, my friend, do not have 256 colors.

Step 1

Your Terminal

Check your terminal.

Some terminals support 256 colors, while others may not. Since I'm working with Ubuntu, and gnome-terminal is pretty darned good at its job, I was glad to find that it supports 256 out of the box. Horray!

But let's make sure. Here is a small perl script that will output a 256 color grid in your terminal. You should get something that looks like this:

The perl script is originally found at

Step 2


Configure Vim

Vim is easy to configure for 256 color use. Just add the following to your .vimrc or other configuration:

set t_Co=256

That's it. Try it out with one of the schemes from above to make sure it looks decent before moving on.

Step 3


Configuring Screen

GNU screen, the wiliest of them all. Ubuntu was nice enough, around 2008 to enable 256 color support in screen, however, for some reason, does not ship with this option enabled.

Update your .screenrc file and add the following:

attrcolor b ".I"
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E38;5;%dm'
defbce "on"

I suggest copy and pasting that without trying to understand it. No one understands termcap stuff.

Selling Out

Putting Google Ads In