How do I create custom highlight groups and override colorscheme colors?
Answer
:highlight MyGroup guifg=#ff0000 guibg=NONE gui=bold
Explanation
The :highlight command lets you define custom colors for syntax elements, UI components, and your own highlight groups. This is how you customize your editor's appearance beyond what colorschemes provide.
How it works
:highlight {Group} {key}={value}— set highlight attributesguifg/guibg— foreground/background for GUI and terminal withtermguicolorsctermfg/ctermbg— foreground/background for 256-color terminalsgui/cterm— attributes:bold,italic,underline,reverse,NONE
Example
" Custom highlight group
highlight MyGroup guifg=#ff0000 guibg=NONE gui=bold
" Override an existing group
highlight Comment guifg=#888888 gui=italic
" Link one group to another
highlight! link MyGroup ErrorMsg
" Clear a group
highlight clear MyGroup
Tips
- Place overrides in
after/plugin/colors.vimso they load after colorschemes - Use
autocmd ColorScheme * highlight ...to preserve overrides when switching schemes :highlight(no args) lists all active highlight groups:so $VIMRUNTIME/syntax/hitest.vimshows all groups with their colors