I want to customize a syntax coloring in vim for c++. But, unfortunately, i still can't find a correct name for braces (){}[] and operators +-/*% for c/c++/objc/objcpp. Any vim guru whi can suggest what name i must 'hi' in order to set color for items mentioned?
相关问题
- Emacs shell: save commit message
- How to change the first two uppercase characters o
- Insert text into current buffer from function
- Hot reload on save
- Substituting zero-width match in vim script
相关文章
- 如何让 vim 支持 .cshtml 文件的代码高亮
- Auto-save in VIM as you type
- How can I use gcc's -I command to add recursiv
- Vim: overloaded mapping for multiple modes
- How to use relative line numbering universally in
- How to copy the value of a vim option to a registe
- E185: Cannot find color scheme*
- How do I fix vim to properly indent folds containi
@pepper_chico mentioned rainbow plugin. Many forks now exists for it. The best that I have found is this Rainbow Parantheses Improved. Its actively developed. And it works for many many filetypes rather than just cpp.
Here I will depict installation for Vundle see the link for other ways to install. Vundle plugin install line for this is
Then to install pass the following commands to vim
After this you can add this to your .vimrc for further configuration
Do note the difference in the operators field above and in config in the link I provided. The advanced config given in link only highlights comma
,
I have edited that to include more operators. Edit that line according to your taste to add some more. This is the result:Note the change in color because of nesting
Get my fork of Rainbow Parentheses Improved (it deals with operators too): https://github.com/oblitum/rainbow
Firstly, get the rainbow colors to working with c, cpp, or whatever lang you desire. which is explained on the download page. http://www.vim.org/scripts/script.php?script_id=1230 , then copy the plugin to a new.vim then vim new.vim and change all the ( and ) to { and } respectively, and save. now redo the getting it working with c, ... (whatever lang) part, but this time change the name to new.vim (or whatever you called it!!) and that worked for me.
the '[' are similar
I believe that there is no default highlighting for braces as standard in vim for C code or derivative languages (they're just highlighted as plain text). You could define your own, using something like:
or you could download the rainbow brace highlighting plugin, which gives varying colours for different levels of indentation. See also my answer to this question.
There is a screenshot of the rainbow brace highlighter in action (with my Bandit colour scheme) here.
Edit:
In order to find out the highlighting group of anything that interests you, create this mapping:
(taken from here). Then, move the cursor over whatever you're interested in and press F3. If it's not highlighted at all, Vim will print:
If there's a particular highlight group, you'll get something like this (with the cursor over the
if
keyword):which tells you that the highlight group is called
cConditional
and that it is linked (with:hi link
) to the group calledConditional
. With rainbow brace highlighting, you may get something likecCurly1
, which means it's inside a curly brace, but with no additional highlighting.Edit 2:
A possible operator matcher (not very well tested):