[Tip] activating 256 colors support in vim

Roland Wolters

bash.pngOne of the many advantages of vim is the possibility to use syntax highlighting: different terms and chars are displayed in different colors according to their meaning and function.The more colours are available, the better - however, in many cases vim falls back to 8 or 16 colors by default. This can be quickly changed with an entry in ~/.vimrc:

if &term!="xterm"
   set t_Co=256            " use 265 colors in vim
   colorscheme desert256   " an appropriate color scheme

With this configuration, vim from now on uses 256 colors - and the second line makes sure you a color scheme which actually uses that many colors: desert256 - but make sure you copy the color scheme file to ~/.vim/colors/ before! The if-query ensures that the configuration is not loaded on ttys where you usually don't have 256 colors.

By the way: an overview of all kinds of color schemes with "screenshots" for different programming languages can be found at the vimcolorschemetest project web page.

Blog Categories: 

Add new comment