Have you ever opened a massive codebase and wished you could jump straight to the definition of a function, class, or variable without scrolling endlessly? That's exactly what CTags is for.

In this post, we’ll break down what CTags is, how to use it, and—most importantly—how to read a tags file

What is CTags?

CTags (short for "C Tags") is a tool that scans your code and generates an index of where functions, variables, classes, and other identifiers are defined. This index is saved in a file called tags.

Let's Try It Out!

Suppose you have this simple math_utils.py file:

def add(a, b):
    return a + b

def subtract(a, b):
    return a - b

Run this in your terminal:

ctags -R .

You’ll now see a file called tags in your directory.


What’s Inside the tags File?

Here’s what it might look like:

add math_utils.py   /^def add(a, b):$/;"    f
subtract    math_utils.py   /^def subtract(a, b):$/;"   f

Let’s decode a single line:

add math_utils.py   /^def add(a, b):$/;"    f

What these mean

Part Meaning
add The tag name (identifier name—like a function, variable, or class).
math_utils.py The file where the tag is found.
/^def add(a, b):$/; A search pattern to find the tag in the file. This is a regex that editors like Vim use to jump straight to it.
f The tag type. In this case, f stands for function.

Other common tag types include:

  • c — class
  • v — variable
  • m — member
  • F — file

Configuring ctags

You can tweak what CTags picks up using .ctags config file. Example:

--languages=Python
--exclude=tests
--fields=+n

This:

  • Only tags Python files
  • Skips tests folder
  • Adds line numbers to your tags file (helpful when reading it manually)

Wrapping up

CTags is like a table of contents for your code:

  • Generates a list of where stuff is defined
  • Helps editors jump around faster
  • You can read the tags file yourself—it’s just tab-separated text
  • Powerful for large codebases

If you're a software developer who enjoys exploring different technologies and techniques like this one, check out LiveAPI. It’s a super-convenient tool that lets you generate interactive API docs instantly.

So, if you’re working with a codebase that lacks documentation, just use LiveAPI to generate it and save time!

You can instantly try it out here! 🚀