Using Ctags efficiently with Vim
Here is the video of the same if you prefer to watch a video of this instead.
Setting up ctags for your source code
Use the exuberant ctags if you are on windows from http://ctags.sourceforge.net/
Then you can set up ctags by using something like this
c:\tools\ctags —c++-kinds=+p —fields=+iamS —extra=+fq —recurse=yes —languages=c++ —tag-relative=yes -f c:\tags\tags
You will have to do this regularly (everytime you make a change to your sources essentially) to generate new tags. Its good to add this to your post check-in script if your source code server supports that.
Setting up vim to use your tags files
Now in your ~/_vimrc you can set up tags like
set tags+=./TAGS;/,../TAGS,c:\tags\TAGS
The above command tells vim to look for TAGS file in current directory, parent directory and in c:\tags directory to build its tag table
Basic Commands for Navigation
- :ta <tag Name> : This will show the first matching tag and jump there. You can also use the shortcut C-]
- :po : Pop the tag back in tagstack. You can also use C-t to go back.
- :tn, :tp : Move between multiple matching tags
- :ts : This will show the tags stack
- :sta : This will open the tag in split window
- TODO
Advanced Commands
Other helpful plugins
Email me when Vim Tips publishes stories
