Difference between revisions of "Tip 7: etags"
Line 22: | Line 22: | ||
− | In vi, you can load a function directly from the command line: | + | In vi, you can do something similar, but, as far as I know, it only works with ctags (ctags <files>). It is similar, however, but the tags file is formatted a bit differently. load a function directly from the command line: |
vi -t subroutine_name | vi -t subroutine_name |
Latest revision as of 17:55, 2 April 2010
Tags allow you to look up functions quickly from context. For example, if you see a function call "foo(bar)", you can look up the definition of foo with a few keystrokes no matter what file it is in.
If you are using C++:
etags --c++ *.cpp *.h
or add it to your Makefile to automatically update. This will create a TAGS file in your current directory that contains includes locations and defnitions of functions in your program for fast look-up.
In emacs, to load a tag file use:
esc-x visit-tags-table
Once you have the tags table loaded you can:
esc-.
Find a definition for a tag. The default tag is identifier under the cursor. Name completion type partial name and then TAB.
ctrl-x 4 . TAG
Display tag in new window.
esc-,
Find the next definition for the tag.
esc-*
Pop tag stack (go back one level)
In vi, you can do something similar, but, as far as I know, it only works with ctags (ctags <files>). It is similar, however, but the tags file is formatted a bit differently. load a function directly from the command line:
vi -t subroutine_name
or within vi:
:tag subroutine_name
or by placing your cursor over the function and typing:
ctrl-]
More information is here: