Gutentags for Vim
Autotags is my second “official” Vim plugin (after Lawrencium). It confirms
a trend of having a terrible name (although this time for different reasons),
but I’m open to changing it since it’s still early. And as that terrible name
implies, this new plugin is all about automatically managing your tags.
Edit: thanks to Reddit, it was renamed to Gutentags! I edited this
post after this point to use the updated name and links.
One of the biggest problems you face when using Vim with a large codebase – and
one of the reasons most users still go back to an IDE for their day job – is
that tags files in Vim suck. No wait, it’s not even that they suck, it’s that
there’s nothing out of the box to help you with it. Which, well, sucks.
In case you don’t know, tags files are basically a reverse index of the symbols
defined in a given codebase, as generated by an external tool like Ctags.
This is what lets you put the cursor on a function call and jump to the
definition of that function. It’s basic stuff that “just works” in an IDE1,
but in Vim you need to create, update, and otherwise manage that thing yourself.
It’s insanely archaic even by Vim’s standards.
In case you’re wondering how this plugin is different from the many other
similar plugins out there, or from just doing it the retarded way (i.e. run
!ctags -R . every now and then), here it is:
- No dependencies on anything else than Vim and Ctags: no Python, Ruby, or
- Cross-platform: should work at least on Mac and Windows at the moment, Linux
should be fine too2.
- Automatically index new projects: when you open a file in a new project,
Gutentags will start indexing it right away. You don’t need to manually run it
if you don’t want to.
- Incremental tags generation: when you edit and save a file, Gutentags will
properly and automatically update the index, but only for that file.
Re-generating the whole index obviously doesn’t scale for large codebases, yet
that’s what most tutorials tell you to do! This is madness and it has to stop.
- Background update: you shouldn’t have to wait while the index is (re)generated
(which is what
!ctags -R .does! Again, madness).
- Keep tags files away: don’t like to see lots of
tagsfiles polluting your
projects everywhere? Tired of adding
.hgignorefile ever? Me too. Gutentags lets you keep them in a hidden place
of your own choosing.
At the time of writing this post, Gutentags has been tested on a glorious total
of 3 machines (all my own with the same Vim configuration), so watch
our for bugs, and please report them on Github or BitBucket.
The usual disclaimers are in effect (this is a random piece of code you found
on someone’s blog!), but I just want to warn you that since this plugin kicks off
ctags processes, there could be bugs that will generate humongous
tags files while saturating your laptop’s CPU and ending up burning your balls
and/or snatch. Again, report them via Github/Bitbucket after calling
your local emergency dispatch centre.