Ubuntu – VIM colors in terminal look very dry

colorsterminalUbuntuvim

I've been trying out a few different vim color schemes but none of them ever look like the picture (they seem very dry, not as colorful). I have tried messing with all the "profile preferences" on terminal but they don't seem to fix the color issue. I'm on Ubuntu 11.04 Beta 1. Any suggestions are appreciated.

Best Answer

The ANSI X3.64 standard only specifies 16 colors, and it's what Xterm declares in its terminfo description for "xterm". (GNOME Terminal is Xterm-compatible and uses the same terminfo description too.)

Current versions of both Xterm and GNOME Terminal have a 256-color mode. Since most programs use terminfo to decide whether to use 256 colors, you need to set $TERM apropriately. For example, if it was xterm, change it to xterm-256color.

export TERM="xterm-256color"

Restart vim after running this command.


One way to do this permanently is to add the following to your ~/.bashrc file:

case $TERM in
    xterm|screen|rxvt-unicode)
        TERM="${TERM}-256color" ;;
esac

It is, of course, even better to configure this setting in the terminal emulator itself (e.g. XTerm*termName), but some terminals have it hardcoded (as with gnome-terminal), in which case ~/.bashrc is acceptable as long as it doesn't set the new value blindly.


Inside vim, you can use :set t_Co? to check whether it successfully detected 256 color mode. Do not change this value inside your .vimrc, though, as it would be very unreliable.


Of course, nothing can beat gvim, which as a graphical program can use the full 32-bit color range.

Related Question