Code Yarns β€πŸ‘¨β€πŸ’»
Tech Blog ❖ Personal Blog

How to use Exuberant Ctags

πŸ“… 2013-Feb-02 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ ctags, exuberant ctags, ubuntu, vim ⬩ πŸ“š Archive

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


Β© 2022 Ashwin Nanjappa β€’ All writing under CC BY-SA license β€’ 🐘 @codeyarns@hachyderm.io β€’ πŸ“§