2

vim has some great highlighting for built-in keywords, functions and types, but when working on some non-built-in projects, this seems not enough.

For instance, the keyword before a variable is mostly a type keyword. Take a gtk program for example:

In vim:

first

Where the three GtkWidgets should be marked as type as that in SO:

SO

These are some basic syntax for the C language. Can one in vim do the same highlighting?

  • 1
    I don't think this is possible for Vim in the general case. To distinguish a b(c); as a function declaration or a variable declaration, you have to know whether c is a type. For just a b, it might be possible. – muru Mar 24 '16 at 19:18
3

There are several plugins in vim.org that should accomplish that, for instance:

If no existing plugin work as you expect them you should consider writing a new one (and possibly including it in vim.org) by following the explanation in :help usr_44 -- "Your own syntax highlighted".

  • Hmm, the syntax highlighting are good, though I think vim can do as that like compilers to distinguish types, vars, and functions (which is my original thought) , it will definitely be complicated. – Chromium Mar 24 '16 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.