Difference between revisions of "Tip 7: etags"
(Created page with 'For use with 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 loc…') |
|||
Line 1: | Line 1: | ||
− | For | + | 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 | etags --c++ *.cpp *.h |
Revision as of 17:49, 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 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: