How to use Exuberant Ctags

Good tools to navigate and understand source code is essential when dealing with large projects. Such capabilities are built into IDEs like Visual Studio and Eclipse. However, if you are using Vim, one of the best options is Exuberant Ctags.

Exuberant Ctags provides the ctags program that can be used to generate a tag file containing tags for source files of a project. Editors like Vim can use this tags file to help you navigate through type, variable or function definitions of the source code.

First, install the package using exuberant-ctags as the package name.

Next, go to the directory with source code and use ctags to generate tags for the source files there. By default, it works on only the files in the current directory. Typically, you want it to chomp through files in all the subdirectories too. This can be done by using the recursive option:

$ ctags -R *

Now open any file of the project in Vim and indicate the location of the tags file:

:set tags=/path/to/tags-file

Congrats! Now you can jump back and forth to definitions. For help on this see :help tags

Tried with: Vim 7.3, Exuberant Ctags 5.9 and Ubuntu 12.04 LTS

5 thoughts on “How to use Exuberant Ctags”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s