Whenever I'm typing programming keywords in vim they get specific colors.
I'd like to create my own.
How can I color text with specified color?
I tried to find the answer but haven't found it yet
to extend C/CPP syntax (and that can apply to any language, just check for the already existing names, like Constant
here) :
in your ~/.vimrc
if has("autocmd")
augroup filetypedetect
au BufNewFile,BufRead *.myext setf mysyntax
augroup END
endif
and in your ~/.vim/syntax/mysyntax.vim
runtime! syntax/cpp.vim
syn keyword myConstant foo bar foobar quack
hi def link myConstant Constant
to create new keywords from scratch :
syn match myKeyWord "foobar" contained
hi kwRed term=standout ctermfg=12 guifg=Red
hi def link myKeyWord kwRed
and you can call that with filetypedetect
, or directly in your .vimrc
To extend a particular filetype syntax (like e.g. Java's), use :syntax
and :highlight
. If you just want to color particular words in a window, you can quickly use :match
, or any of the available "multiple markers" plugins like mark.vim.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With