OSX + Vim + CTags (Exuberant) for fast context switching in large projects
Nov 30, 2011 - 1 minutesInstalling CTags (Exuberant)
Lets first install ctags-exuberant using Homebrew
1brew 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:
1let Tlist_Ctags_Cmd='/usr/local/Cellar/ctags/5.8/bin/ctags'
2
3let g:Tlist_Ctags_Cmd='/usr/local/Cellar/ctags/5.8/bin/ctags'
4
5fu! CTagGen()
6 :execute "!" . g:Tlist_Ctags_Cmd . " -R ."
7endfunction
8
9nmap <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]({{ site.s3 }}posts/ctag_vim.jpg)
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!).