Wednesday, January 26, 2011

Very colorful vim

It seems that xterms and screen are slowly clawing their way into the 21st century... We can now view our code in more than 16 colors. There are a few hoops you'll need to jump through to get it working.




  • Make sure tmux is 256 ready, editing your ~/.tmux.conf

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



  • Make sure screen is 256 ready, editing 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"


  • Check your terminal supports 256 colors

    • colortest

    • Run that in and out of screen

    • If you find that the gradient doesn't print what you expect, you may need to recompile screen with the configure option --enable-colors256

    • If that doesn't work, you may need to recompile X...


  • Update your .vimrc

    • syntax on

      set t_Co=256



You can now begin using some super fancy color schemes with vim. While in vim, use :colorscheme to test drive the many and varied options. Fortunately, colorscheme supports tab completion and it will search your system (/colors) and user (~/.vim/colors) runtime directories. Once you've settled on a scheme you like, add the command to your .vimrc.



Very nice (am I crazy, or are a bunch of these fifteen year old emacs color schemes)



Not too shabby

No comments:

Post a Comment