Ubuntu – How to enable full-color support in Vim

colorscommand linevim

I have a lovely Vim colorscheme (xoria256) and it looks brilliant in GVim, but when I use normal vim in Terminal, the colorscheme is only partially supported — for example, the default semi-transparent aubergine background color is used. How do I make Terminal faithfully render my Vim colorscheme?

Best Answer

GNOME Terminal supports 256 colors, but doesn't advertise its support. You can override vim's autodetection by putting the following:

if $COLORTERM == 'gnome-terminal'
  set t_Co=256

in your ~/.vimrc.

Note: if you use GNU screen, it will happily eat those 256-color codes and convert them to basic 16 colors. A better fix is to change TERM to xterm-256color before launching screen/vim.

Update for 2017: if you have a sufficiently recent Vim (7.4.1799 or newer), and a sufficiently advanced terminal emulator (xterm, or gnome-terminal based on a sufficiently recent version of VTE), you can :set termguicolors and terminal vim will use full 24-bit colors as defined by your vim theme using highlight guifg=#rrggbb guibg=#rrggbb.

Related Question