At the Beginning of this year, I’m going to start reading Computer System A Programmer's Perspective, this whole book introduces the different aspects of computer system basing on C language, and there’s also plenty of C demos provided in the web, to navigate the code, I try to use ctags.

What is Universal Ctags?

Universal Ctags (abbreviated as u-ctags) is a maintained implementation of ctags. ctags generates an index (or tag) file of language objects found in source files for programming languages. This index makes it easy for text editors and other tools to locate the indexed items.

Install in Mac

brew tap: A tap is Homebrew-speak for a Git repository containing extra formulae.

brew tap universal-ctags/universal-ctags
brew install --HEAD universal-ctags

Configure .vimrc

#search the .tags in the current directory, will keep searching the upper directory if not found
set tags=./.tags;,.tags

Setup alias for ctags

Because there is already a ctags command in Mac, which is /usr/bin/ctags, we need to create an alias of ctags for overwriting.

Add this in .zshrc (suppose to use zsh)

  • alias ctags="/usr/local/bin/ctags"

    which ctags to verify

Generate tag recursively

In the root of the project:

  • ctags -f .tags -R .
    • -f .tags indicates that the output file is .tags
    • -R means --recurse