Search code examples
c++vimsyntax-highlightingtextmatevim-syntax-highlighting

class & function names highlighting in Vim


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)
(source: ivzhao.com)

Any ideas how to solve this? It really annoys me as I am so much a visual-sensitive guy.


Solution

  • 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:

    :hi Function guifg=red
    

    or

    :hi Identifier guifg=red
    

    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