I just recently set up my Vim environment from Textmate, after becoming addicted to its modal input.
However, syntax highlighting seems to be not so beautiful in Vim. I code in C++ and since the function call and class names can't be highlighted, the code is more difficult to read. I played with color scheme for a bit, but couldn't find any field that corresponded to "class name" or "function name".
In the picture below, notice how DroughtLayer::
and *.size()
is not highlighted on the right in MacVim.
Picture comparison between Textmate(left) and Vim(right) http://ivzhao.com/temp/vimHL.png
Any ideas how to solve this? It really annoys me as I am so much a visual-sensitive guy.
Interestingly, the syntax highlighters in VIM don't support applying a syntax to identifiers or function names - at least not the syntax highlighters for C and C++. So, even if you do:
or
it doesn't give these a color. I just seems to be not much more than keywords and constants for these languages.
Here, someone has started extending the cpp syntax file to support method names. It's a start I guess. http://vim.wikia.com/wiki/Highlighting_of_method_names_in_the_definition
Try using this plugin http://www.vim.org/scripts/script.php?script_id=2646 Its does all ctags highlighting very efficiently for you
I really recommend you the
taghighlight
plugin, click here for it's website.this is my first post here and i didn't know how to make an observation, the answer of Eduardo makes "(" and "{" look unmached and bugs syntax foldind, I changed it a little to fix this.
Sergey, changing the first line from
to
seems to fix it for me.
I had this very same problem when I started using vim. The solution is simple, you just have to edit the c syntax file used by vim, here's how to do it:
When you start editing a C or C++ file, vim reads the default c syntax file located in
(Where $VIMRUNTIME is where you have vim installed. You can find out it's default value by opening vim and using the command ":echo $VIMRUNTIME").
You can simply overwrite that file, or you can create your custom C syntax file (which will be loaded by vim instead of the default one) in this location:
(I have never used a Mac so I dunno which one will work for you. You can find out more in the vim help, ":help vimfiles")
Now the fun part. Copy the default "$VIMRUNTIME/syntax/c.vim" file to your vimfiles directory ("$HOME/.vim/syntax/c.vim" for UNIX), and edit it by adding these lines:
That's it! Now functions and class names will be highlighted with the color defined in the "Function" highlight (":hi Function"). If you want to customize colors, you can change the last two lines above to something like this:
or you can leave the C syntax file alone and define colors in your vimrc file (":help vimrc"):
(Note the absence of the "def" keyword, go to ":help highlight-default" for details). For the available parameters to the ":hi" command see ":help :highlight".
You can find the complete c.vim file for Vim 7.2 on this link (Note: only use this if you have a non-modified Vim, version 7.2):
And the obligatory screenshot: