Aug 10, 2010 vim

Notes on Vim colors for syntax highlighting.

Work in progress

I am currently working on a new vim colorscheme otter-dark with the following features:

Once finished, it will be uploaded to:


Preview all themes and colorschemes

Built-in colors

$ ls /usr/share/vim/vim73/colors

default.vim    elflord.vim    morning.vim    peachpuff.vim  slate.vim
blue.vim       delek.vim      evening.vim    murphy.vim     ron.vim        torte.vim
darkblue.vim   desert.vim     koehler.vim    pablo.vim      shine.vim      zellner.vim


Load color scheme, see above.

:colorscheme desert
:colorscheme peachpuff

:color twilight

see for function that switches color theme using F8. Also made into plugin.

Change color

displays all highlighting text



:help hi

Set color

:set hi <E> cterm= ctermbg= ctermfg= guibg= guifg= 
cterm__ : terminal based vim (most case)
gui__ : gui-based vim (gvim, macvim)

Reset colors

:hi clear
:hi clear {group}

Highlight cursor line

:hi Cursor guifg=NONE guibg=Green


" show cursorline. *cursorline may cause slowdown in large file/ long text
set cursorline
hi CursorLine cterm=NONE ctermbg=233  "cursorline color: grey7"


vim colorscheme preview/editor

vim colorscheme preview

vim plugin: colorscheme pack

Includes solarized, tomorrow, and zenburn.

Vundler: add to .vimrc

Plugin 'flazz/vim-colorschemes'

[Ruby code that harvests the colorscheme from] (

Good colorschemes


Example setting

set background=dark
let g:solarized_termtrans=1
let g:solarized_termcolors=256
let g:solarized_contrast="high"
let g:solarized_visibility="high"
colorscheme solarized

Toggle between dark and light background (using F5)

call togglebg#map("<F5>")

Create colorscheme

create colorscheme based on existing colors

"these lines are suggested to be at the top of every colorscheme
hi clear
if exists("syntax_on")
syntax reset

"Load the 'base' colorscheme - the one you want to alter
runtime colors/blue.vim

"Override the name of the base colorscheme with the name of this custom one
let g:colors_name = "my-blue"

"Clear the colors for any items that you don't like
hi clear StatusLine
hi clear StatusLineNC

"Set up your new & improved colors
hi StatusLine guifg=black guibg=white
hi StatusLineNC guifg=LightCyan guibg=blue gui=bold

Compatibility Issues

vim and tmux

Cause: shell uses $TERM=xterm-256color but tmux uses $TERM=screen-256color.

Solution 1:

set $TERM=screen-256color (


`alias tmux="TERM=screen-256color-bce tmux"`

Solution 2. Disable BCE (background color erase)

:set t_ut=
<C-L> to refresh

It works, but I need to do it for every time starting vim.

I need to make a script or macro to do this every time.

if &term =~ '256color'
    " disable Background Color Erase (BCE) so that color schemes
    " render properly when inside 256-color tmux and GNU screen.
    " see also
    set t_ut=

Solution 3:

Make gvim colorschme work on terminal vim.

In case vim doesn’t recognize colored terminal:

if $TERM == "xterm-256color" || $TERM == "screen-256color" || $COLORTERM == "gnome-terminal"
  set t_Co=256


Save as HTML (including color)

visual mode, highlight the text

# this will open a new buffer with generated HTML, which can be saved

:TOHtml tutorial (generate HTML from Vim in color)

256 xterm color chart

Vim Plugin that shows color

Vimshell does not use escape sequence color. To use escape sequence, enable |+conceal| feature. It works with Vim 7.3+.