vimtricks.wiki Concise Vim tricks, one at a time.

How do I customize syntax highlighting colors?

Answer

:highlight Group ctermfg=color

Explanation

The :highlight command changes the appearance of a highlight group. You can modify colors for any syntax element, UI element, or custom group.

How it works

  • :highlight Comment ctermfg=gray makes comments gray
  • ctermfg sets the foreground color in terminal
  • ctermbg sets the background color
  • cterm=bold,underline sets text attributes

Example

highlight Comment ctermfg=green
highlight LineNr ctermfg=darkgray
highlight Search ctermbg=yellow ctermfg=black
highlight StatusLine ctermbg=blue ctermfg=white

Tips

  • :highlight with no arguments shows all groups
  • Use guifg/guibg for GUI Vim or terminals with true color
  • :highlight link GroupA GroupB makes GroupA use GroupB's colors
  • :highlight clear resets all highlighting
  • Colors: black, red, green, yellow, blue, magenta, cyan, white, and numbers 0-255

Next

How do you yank a single word into a named register?