VIM Colorschemes in Screen & PuTTy?

Patrick O'Doherty picture Patrick O'Doherty · Oct 27, 2009 · Viewed 9.8k times · Source

I've been trying to get colourschemes to work properly in VIM when using it over ssh with PuTTy as a client but unfortunately I haven't had much success. I can only get 8bit colours working with PuTTY even though I've enabled 256 colors in putty and set t_Co=256 in VIM. They don't turn out as they should. I've been trying to replicate this setup http://www.interworksinc.com/blogs/ckaukis/2009/06/03/vim-color-schemes-putty but as I say it's been in vain so far.

Has anyone here had success with colourschemes working with VIM in PuTTy? I'd appreciate any advice

Thanks,

Patrick

[EDIT] Turns out I've found the source of the problem. I was using vim in a screen which was breaking the colours. Updated question I guess is, is it possible to have working colors in a screen session? [/EDIT]

Answer

Edd Steel picture Edd Steel · Jan 29, 2011

As well as compiled support, it may be necessary to add some config to screenrc (I needed to).

http://www.frexx.de/xterm-256-notes/ has a good guide. The relevant part to screen:

By default, screen is not aware that it is running in a 256 color capable xterm. To make programs in screen recognize this feature, you need to set three things in your ~/.screenrc:
# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I" 
# tell screen how to set colors. AB = background, AF=foreground 
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm' 
# erase background with current bg color 
defbce "on"