Notes on Vim colors for syntax highlighting

Load color scheme, see above.

:colorscheme desert
:colorscheme peachpuff

:color twilight

Use [F8] to switch colorschemes. see Also made into plugin.

:NextColorScheme    # also [F8]
:PrevColorScheme    # also [Shift][F8]

Conditionally load colorscheme (gvim and terminal vim)

" [VIM and Python – A Match Made in Heaven – Real Python](
if has('gui_running')
  set background=dark
  colorscheme solarized
  colorscheme zenburn


Preview all themes and colorschemes

Built-in colors

$ ls /usr/share/vim/vim80/colors

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

Change highlight color

Displays all highlight setting for text



:help hi

Disable highlight

:hi clear

:hi clear <group>


Named GUI Colors

  • From vim help: Suggested color names (these are available on most systems):

    Red     LightRed    DarkRed
    Green   LightGreen  DarkGreen   SeaGreen
    Blue    LightBlue   DarkBlue    SlateBlue
    Cyan    LightCyan   DarkCyan
    Magenta LightMagenta    DarkMagenta
    Yellow  LightYellow Brown       DarkYellow
    Gray    LightGray   DarkGray
    Black   White
    Orange  Purple      Violet

GUI special color

    NONE        no color (transparent)
    bg      use normal background color
    background  use normal background color
    fg      use normal foreground color
    foreground  use normal foreground color

For ctermfg, ctermbg, use xterm color name/number GUI color names: x11 color names

GUI color using RGB


Plugin to show all colors

Simple vim code to show colors

" file: showcolors.vim
let num = 255
while num >= 0
    exec 'hi col_'.num.' ctermbg='.num.' ctermfg=white'
    exec 'syn match col_'.num.' "ctermbg='.num.':...." containedIn=ALL'
    call append(0, 'ctermbg='.num.':....')
    let num = num - 1

Set color

:hi <groupname> term= cterm= ctermbg= ctermfg= guibg= guifg= gui=
  • term=<attribute> : normal terminal (vt100, xterm):

    • bold, underline, italic, reverse, etc
    • NONE :reset attribute
  • ctermfg/ctermbg=<cterm-color> : color terminal (most case), set color

  • gui=<attribute>

    • bold, italic, underline, inverse/reverse, etc
    • NONE :reset attribute
  • guifg/guibg=<GUI-color> : gui-based vim (gvim, macvim), set color


:hi htmlH1 ctermfg=red gui=BOLD guifg=RED
:hi htmlH2 guifg=green ctermfg=NONE
:hi htmlh3 guifg=purple

Get current color setting for bold and italic (html/markdown):

:verbose highlight htmlBold
:verbose highlight htmlItalic

Set color for bold and italic (html/markdown):

highlight htmlBold gui=bold guifg=#af00ff ctermfg=129
* 129 = Purple = #AF00FF

highlight htmlItalic gui=italic guifg=#870087 ctermfg=DarkMagenta Highlight ugly code:

highlight any long lines exceeding 120 characters

match ErrorMsg '\%>120v.\+'

highlight any lines with trailing whitespace

match ErrorMsg '\s\+$'

Reset colors

  • :hi clear : reset colorscheme setting to default (i.e. colorscheme default)
  • :hi clear {groupname} : clear/disable certain highlighting
  • :syntax reset reset all color & syntax to default, if it gets messed up after customizing

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"

Default common highlighting

Default highlighting file: /usr/share/vim/vim80/syntax/syncolor.vim

Override default with custom highlighting file: ~/.vim/after/syntax/syncolor.vim


2 background type: light, dark

Switch to dark background

set background=dark

differentiate light and dark background

" Example from Vim help

if &background == "light"
  highlight comment ctermfg=darkgreen guifg=darkgreen
  highlight comment ctermfg=green guifg=green

Modify existing colorscheme

From vim help:

To customize a colorscheme use another name, e.g. “~/.vim/colors/mine.vim”, and use :runtime to load the original colorscheme:

    runtime colors/evening.vim
    hi Statement ctermfg=Blue guifg=Blue
  • colorscheme mine will load colorscheme from ~/.vim/colros/mine.vim and that will in turn load original colorscheme


Color previewer

Vivify: vim colorscheme preview/editor

  • Highly recommended!
  • quick 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



  • My favorite, made by Steve Losh. Looks great on markdown.
  • Markdown’s >> is too gray, hard to read

Good built-in


good high-contrast colorthemes

  • distinguished : too bright, no. but many like it.
  • railscasts
  • candy
  • grb256 : based on ir_black.
  • wuye
  • babymate256 : string color is too bright.

low-contrast colorschemes

Base16-based palette

  • see base16-* colors
  • base16-railcasts

  • twilight: clone of TextMate’s twilight.

  • twiligth256: does not work

  • jellybeans - nice, pleasant text color, inspired by Twilight

    • has lots of extra codes,
    • lots of extra highlights certain words.
    • override color by

      let g:jellybeans_overrides = {
      \    'Todo': { 'guifg': '303030', 'guibg': 'f0f000',
      \              'ctermfg': 'Black', 'ctermbg': 'Yellow',
      \              'attr': 'bold' },
  • codeschool: very complete definitions.

  • tesla

  • tomorrow-night

    • not included in the pack.
    • doesn’t highlight headers (H1,H2,…) and header in markdown
  • nordisk

    • based on Nord (artic, north-bluish color palette)
  • chance-of-storm: nice, low-contrast delimeters, URL/float

    • excellent skeleton code to start out customized color
    • markdown
  • zenburn

    • low-contrast colors scheme
    • too yellowish for my taste, don’t like green comments
  • Despacio

    • inspired by Moonshine, Railcasts, and Zenburn
    • see settings
    • same maker of Alduin, Sierra




* high and low-contrast
* couldn't get to work in MacVim - all too bright


* not-too high, not-too low,
* WYSIWIG syntax highlight preview


* slightly bright
* 24bit colorscheme, vim, airline,
* Fix on MacVim:  let macvim_skip_colorscheme=1


* Japanese traditional colors
* seems slightly bright


* works with MatchTagAlways plugin


  • suports NeoVim’s new highlight group
  • looks weird in Markdown
  • comment with “.” gets bright highlight



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>")
  • some themes (such as Solarized) have both dark and light themes

Create or customize colorscheme

Good example to base off of


  • Source
  • styling guide for syntax highlighting, limits to 16types
    • base00 - Default Background
    • base01 - Lighter Background (Used for status bars)
    • base02 - Selection Background
    • base03 - Comments, Invisibles, Line Highlighting
    • base04 - Dark Foreground (Used for status bars)
    • base05 - Default Foreground, Caret, Delimiters, Operators
    • base06 - Light Foreground (Not often used)
    • base07 - Light Background (Not often used)
    • base08 - Variables, XML Tags, Markup Link Text, Markup Lists, Diff Deleted
    • base09 - Integers, Boolean, Constants, XML Attributes, Markup Link Url
    • base0A - Classes, Markup Bold, Search Text Background
    • base0B - Strings, Inherited Class, Markup Code, Diff Inserted
    • base0C - Support, Regular Expressions, Escape Characters, Markup Quotes
    • base0D - Functions, Methods, Attribute IDs, Headings
    • base0E - Keywords, Storage, Selector, Markup Italic, Diff Changed
    • base0F - Deprecated, Opening/Closing Embedded Language Tags e.g. <?php ?>

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

Badwolf made by Steve Losh. A good example to learn from.

Javascript-specific highlighting

  • adds additional highlighting
  • used by Sierra colorscheme

Compatibility Issues

  • Many colorscheme require 256 color terminal.

vim and tmux

  • tmux leaves parts of background color unpainted.

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"`
  • however, it creates a problem with certain keyboard shortcuts.

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

Fix highlighting


:syntax sync fromstart

Slightly faster using # of lines

:syntax sync minlines=200

Assign F5 to fix syntax highlighting - adopted from

noremap <F5> <Esc>:syntax sync fromstart<CR>
inoremap <F5> <C-o>:syntax sync fromstart<CR>


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+.

Tabpage Colorscheme

  • each tab has own colorscheme.
  • old plugin, haven’t been updated in awhile

Work in progress

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

  • distinct color for parenthesis
  • global color setting stored in .vimrc instead of modifying the colorscheme.

Once finished, it will be uploaded to: