Blog

Friday, November 30, 2012

Have you tried ctags with Vim?

After reading Mislav Marohnić's excellent post on Vim, I decided to add ctags to my development environment. What does it buy you? It allows you to jump to method or class definitions with these commands:

<C-]> / :tag foo # jump to tag under cursor/named
<C-]> / :tjump foo # choose from a list of matching tags
view raw 1-mappings.txt hosted with ❤ by GitHub

Setup is pretty easy:

brew install ctags
view raw 2-install.sh hosted with ❤ by GitHub

You can generate tags with:

ctags -R --languages=ruby --exclude=.git
view raw 3-ctags.sh hosted with ❤ by GitHub

But you probably won't want to do all that manually. As Mislav points out in his post, Tim Pope shows us how to automate tag generation with git hooks.

I've been using ctags this afternoon and already it has turned Vim into a completely different editor for me.

Please note this blog is no longer maintained. Please visit CivilCode Inc - Custom Software Development.