To get started, install exuberant-ctags. In Ubuntu, this is just "apt-get install exuberant-ctags". Now, from within Vim:
:cd project_rootTo jump to the definition of the symbol under the cursor, use cntl-]. To get back to where you were, use cntl-o.
:!ctags -R .
:set tags=tags
There's also a taglist plugin for Vim. Once you install that, you can use ":TlistToggle" to open up a window on the left that shows all the things defined in your open files. I have that mapped to "T" by putting the following in my .vimrc: "map T :TlistToggle<CR>".
Thanks to Benjamin Sergeant for helping me get started with ctags.


2 comments:
My problem with ctags is this: with Python (and possibly other languages) it's a pain in the butt to get to the proper definition sometimes. Particularly with duck typing and/or inheritance. If I'm trying to find the definition for the method Goose.fly, I could end up there, or at Duck.fly or Parrot.fly. Vim certainly doesn't make it easy to go to the NEXT .fly method if the first one is incorrect. I have yet to find a good workaround for this.
That's a good point. Certainly with inheritance and duck-typing, you might need to examine all of the implementations.
I just looked at "help tags". There's some useful stuff in the "Tag match list" section.
Post a Comment