Making screen behave like xterm-256ΒΆ

So in a similar vein as the above Colorschemes in VIM section, I was trying to force screen to properly display the colorscheme I had worked so hard to find. Some suggestions I found were to add the set t_Co=256 line to my ~/.vimrc or to invoke vim with -T xterm-256colors. Neither worked. While googling I came across <a href=”http://www.softpanorama.org/Utilities/Screen/screenrc_examples.shtml“>this website</a> which did not deal with the problem directly, but which did have the solution in “Phil’s .screenrc”.

To enable 256 color emulation in screen, simply add the following three lines to your ~/.screenrc:

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

I do not know enough to explain the meaning of these lines, I’m not a screen expert, but I thought this might make it easier for someone else to Google for and find. And for anyone who is skeptical, here is >wombat256_ making vim running inside of a screen session look gorgeous.

../_images/wombat256-in-screen.png