This post is dedicated to people who are already familiar with Ctags, and aims to show you how I use them. If you’ve never heard of Ctags before, and you use a code editor (not an IDE) I HIGHLY encourage you to read about it, then install Universal Ctags.
Now that you know all about Ctags, continue reading! you’ll love it. I think.
Vim
autotag.vim
autotag.vim makes sure your tag files are always up to date.
… using ctags -a will only change existing entries in a tags file or add new ones. It doesn’t delete entries that no longer exist. Should you delete an entity from your source file that’s represented by an entry in a tags file, that entry will remain after calling ctags -a.
autotag.vim fixes this issue by deleting all entries in the tags file referencing the source file that’s just been saved, and then executing ctags -a on that source file.
This is my current configuration:
" put the tags file in the git directory |
Tagbar
Tagbar is a Vim plugin that provides an easy way to browse the tags of the current file and get an overview of its structure. It does this by creating a sidebar that displays the ctags-generated tags of the current file, ordered by their scope…
If you’re a taglist.vim user, you should really check it out.
This is my current configuration:
let g:tagbar_autofocus = 1 |
fzf.vim
fzf is a general-purpose command-line fuzzy finder.
I’ve already written about fzf before, and said that it has complementing vim plugin, fzf.vim.
fzf.vim has a neat :Tags
command that allows fuzzy finding tags. cool right?
Git
Tim Pope (aka: tpope) wrote a great blog post a few years ago about automatic ctag generation using git hooks.
Instead of manual copy-pasting the steps from his blog post, I wrote a script that does that automatically (including updating all current git projects):
- Adds a
~/.git_template
directory for git templates - Copy and configure all ctags hooks in that directory
- Configure
git ctags
alias to generate ctags in the current directory - Recursively walk a given directory and update every folder that’s managed by git, to automatically generate ctags.
After running this script, all current and future git managed projects will have the hooks installed.
|