I recently found this little piece of code for my .vimrc
if has("autocmd")
" Highlight TODO, FIXME, NOTE, etc.
if v:version > 701
autocmd Syntax * call matchadd('Todo', '\W\zs\(TODO\|FIXME\|CHANGED\|XXX\|BUG\|HACK\)')
autocmd Syntax * call matchadd('Debug', '\W\zs\(NOTE\|INFO\|IDEA\)')
endif
endif
Basically, it allows me to define keywords which are matched with different highlighting (Todo and Debug are the names of the colors).
Is there a way that I can define my own coloring schemes and give them names? Specifically what I want to hav开发者_Python百科e is 3 tags: TODO1, TODO2 and TODO3. The idea is that TODO3 is lower priority than TODO1 and thus is highlighted in a lighter shade.
If I can't define my own coloring, where can I find a list of the color names I can use?
If you don't want to use default theme colors, here is the solution:
" Define autocmd for some highlighting *before* the colorscheme is loaded
augroup VimrcColors
au!
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=darkgreen guibg=#444444
autocmd ColorScheme * highlight Tab ctermbg=darkblue guibg=darkblue
augroup END
And later on (this must be after):
" Load color scheme
colorscheme yourscheme
Color definitions follow the format:
autocmd ColorScheme * highlight <ColorName> ctermbg=<TerminalBackgroundColour> guibg=<GuiBackgroundColour> ctermfg=<TerminalFontColor> guifg=<GuiFontColour>
Where the cterm
colors must come from a predefined list (see :help cterm-colors
for more info). Gui colors can be any Hex color.
精彩评论