Code and Life

Programming, electronics and other cool tech stuff

Supported by

Supported by Picotech

Vim Colorschemes with Putty aka. GUI vs. xterm-color256

256 color Vim in Putty

I made a big step in coding geekdom this summer by upgrading the most low-level part of my programming workflow. It started when I got frustrated with Mac keyboard shortcuts on Scandinavian keyboard layout (they Just Don’t Work for most apps), and switched to US layout in coding. Once I made that transition, I started thinking that maybe I could improve my coding speed a bit more, and see what all the fuzz is about Vim.

The greatness of Vim in coding comes from the fact that Vim has separate modes for editing text, and navigating around. While not editing, all normal keys become powerful commands, and you can do text manipulation like duplicating lines, indenting sections etc. without ever leaving this “normal mode”.

Well, Vim is great, but an additional bonus to its power is the fact that almost every *nix system has it preinstalled. So even if I’m not on my own computer, I can just launch an SSH client and use Vim to edit the piece of code I’m working on. No need to compromise. Except color schemes, which I just couldn’t get working over Putty. Today I solved that puzzle after one and half hours of googling, and thought to share the findings, maybe someone will find this the next time they face the problem.

1. Putty can support 256 colors


Putty, my favorite SSH program (on Mac I can just use shell) actually has pretty good 256-color support out of the box. Just go to Window…Colors and check that you have the first three boxes checked and the two after those unchecked.

You should also go to Terminal and check that you have “Use background colour to erase screen” checked. This will avoid black (or whichever default background color you have in Window…Colours) areas in Vim where there is currently no text.

2. Vim also supports 256 colors on terminal, but not by default

To let Vim know that your terminal can do 256 colors, you can either further configure Putty or your shell to set TERM to “xterm-color256” (e.g. export TERM=xterm-color256). Or you can just add a line to your .vimrc (the if is only for those who like to have different settings for ‘mac’ and ‘win32’):

if has('unix')
    set t_Co=256

If you are in luck, you should now be all set. But chances are that you are not…

3. Most Vim color schemes don’t support 256-color terminals

The secret that most Stackoverflow answers don’t tell you is that quite a majority of Vim color schemes only define colors for GUI version of Vim, gVim. For example the “neon” scheme I like defines the normal highlight like this:

hi Normal guifg=#f0f0f0 guibg=#303030

On a terminal Vim, this does absolutely nothing, whereas the “evening” scheme works just fine – can you spot the difference?

hi Normal ctermbg=DarkGrey ctermfg=White guifg=White guibg=grey20

As you can see, the color scheme author has provided color terminal background and foreground options, too. Now one could just grab the 256 xterm colors and do a simple conversion script, but that isn’t actually necessary – there exists a working Vim script to do it automatically, CSApprox. Just unpack it to your .vim folder, or if using Pathogen, make a directory for it under .vim/bundle and restart Vim. Voilà!

Update: colorsupport.vim might actually be even leaner way to achieve the same thing as CSApprox.



Aha! Thank-you very much. It was just the if() part that fixed it for me. I now have lovely 256 colours in Vim on my Raspberry Pi through PuTTY.


I created one cool looking putty color scheme. You can check this out here:


Thanks this was useful! I still am not able to get some schemes to work in putty though such as


I was able to get it to work using :ColorScheme base16-duotone-darkforest

but still doesn’t work in .vimrc via:

ColorScheme base16-duotone-darkforest