TagHighlight

TagHighlight is a plugin that highlights names of classes, variables, types etc in source code in Vim. This makes it quicker and easier to spot errors in your code. By using exuberant ctags and parsing the output, the typedefs, #defines, enumerated names etc are all clearly highlighted in different colours.

The idea was based on the comments in :help tag-highlight, but I wanted to take it a little further.

This is achieved with a python script that interacts with ctags and parses the result, combined with a Vim script that makes Vim read the resulting files.  Finally, a new command (:UpdateTypesFile) is added to keep the generated files up to date.

At present, the highlighter supports the following languages:

  • C/C++
  • C#
  • Java
  • Javascript
  • Matlab (functions only; may require custom ctags version))
  • Perl
  • PHP (experimental)
  • Python
  • Ruby (largely untested)
  • Scala
  • Fortran
  • Go (if your version of ctags supports it)
  • VHDL (if your version of ctags supports it)

Adding more languages is extremely simple.

To show the benefit of this plugin, here are some screenshots of some code (using the "Bandit" colour scheme) with and without TagHighlight (click for bigger):

Without TagHighlight With TagHighlight
Some generic code; dark background:
Some generic code; dark background:
Some generic code; light background:
Some generic code; light background:
regexp.c, from the Vim Source:
regexp.c, from the Vim Source:
kernel/timer.c, from the Linux kernel:
kernel/timer.c, from the Linux kernel:


Other screenshots (all with TagHighlight) are below (more will be added as I get them):

Click for Bigger
Integration with Tagbar (thanks to Alexey Radkov)


The plugin has been tested on Windows and Linux.  It should also work on Mac OS X.  Binaries are available for Windows and Linux for those who don't have python 2.6+ installed (the main application still needs to be installed as this contains the Vim plugin parts).

See the installation guide for more details.

Configuring TagHighlight

For most users, use of TagHighlight should simply be a case of running :UpdateTypesFile when a significant amount of code has changed. Everything else will be handled automatically.

There are some examples of more complex configurations in the documentation (see :help TagHighlight-example-configs). If you have other useful examples, please feel free to add them to the wiki.

Updates

See the change history in :help TagHighlight-history at the end of doc/TagHighlight.txt. The source code is maintained in Mercurial and is available on heptapod (a Git mirror is available on github, although I can't promise this will be as up to date as the heptapod version); the full commit history can be seen on either of these sites.

Feedback

As usual, if you have any comments or suggestions, please contact me using this form or using my email address which is in the documentation and the mercurial commit log.


This website is free, but costs me money to run. If you'd like to support this site, please consider making a small donation or sending me a message to let me know what you liked or found useful.