How do you get Vim to highlight C++ syntax errors like Visual Studio?

teknix picture teknix · Dec 2, 2012 · Viewed 16.4k times · Source

Is it possible to get gVim to highlight C++ syntax errors (the red squiggles underneath) in real-time like Visual Studio?

Answer

Ingo Karkat picture Ingo Karkat · Dec 3, 2012

Short answer: Yes, but it won't be so smooth / immediate as in IDEs.

Long answer: Whereas IDEs have built-in support (and parsers, etc.) for a (usually very limited) set of programming languages, Vim is a general-purpose editor, and therefore has to rely on external tools to do the syntax checking. The built-in way is to execute :make and receive a list of (syntax or compiler) errors in the quickfix list. There are plugins to automate that; Syntastic is a very popular one with support for many languages.

But still, because Vim has to invoke an external executable and has little support for running tasks asynchronously, there will be more delay until you see the errors. If you can't do without the features of an IDE, it's fine to use both according to their strengths: Vim for super-efficient text editing, and the IDE for code navigation, debugging, and compilation.