Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yashdeeph709/98d7dc67a9ed0188c92db18d38f64158 to your computer and use it in GitHub Desktop.
Save yashdeeph709/98d7dc67a9ed0188c92db18d38f64158 to your computer and use it in GitHub Desktop.
Setting up tags is not so difficult, though (as most things in Vim) it's not as automatic compared to IDEs.
First, you need the ctags tool. The most common today is Exuberant Ctags, found at ctags.sourceforge.net.
Next, you need to create a tags database (a file names tags) for all the files in your project(s). This is usually done by running ctags -R . from your project root (also from within Vim via :!ctags ...). Exuberant Ctags support 41 languages, and you can even extend it via regular expressions.
Finally, Vim needs to be configured to pick up the tags database. With :set tags=./tags;, it will search in the file's directory upwards to the root directory. If you have certain global include directories, you can add those.
With that, you can start using Vim's tag functionality like <C-]> and :tag.
You need to periodically update the tags database; there are plugins (like easytags.vim) that can do that automatically for you.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment