Nov 30, 2011 - 1 minutes

OSX + Vim + CTags (Exuberant) for fast context switching in large projects

Installing CTags (Exuberant)

Lets first install ctags-exuberant using Homebrew

1 brew install ctags-exuberant

Remember the path that ctags got installed to, with version 5.8 on my machine it was in:

1 /usr/local/Cellar/ctags/5.8/bin/ctags

Setting up Vim/MacVim

Download the TagList plugin from VimOnline.

In your .vimrc file add the following:

1 let Tlist_Ctags_Cmd='/usr/local/Cellar/ctags/5.8/bin/ctags'
2 
3 let g:Tlist_Ctags_Cmd='/usr/local/Cellar/ctags/5.8/bin/ctags'
4 
5 fu! CTagGen()
6     :execute "!" . g:Tlist_Ctags_Cmd .  " -R ."
7 endfunction
8 
9 nmap <silent> :ctg :call CTagGen()

Open up vim/MacVim, and type

1 :ctg

You can then go to a controller for example:

Type in:

1 :Tlist

And the follow should appear.

ctag list

Lets say I’ve got my cursor on StoryType and I want to go to the model, I can just hit Ctrl+] to get there. You can now do this for any method (helpers, methods, anything thats in your ctags file!).

comments powered by Disqus