URL: http://www.math.fu-berlin.de/~guckes/vim/tags.html URL: https://www.vim8.org/tags.html (mirror) Created: Tue Mar 10 00:00:00 CET 1998 Last update: Tue Mar 10 16:38:40 CET 1998
But what is a tag exactly? How does it work? How can you make use of this?
Let me explian about the "traditional tags" for use with Vi first:
In this respect a tag is like a bookmark, pointer, or reference, ie it gives the location of some other text in some other file.
Definition: A "tags file" is a file which contains a tag on each line. [I am not sure whether comment lines are allowed, though.]
So a tags file is more or less an index of some program which allows to find the definition of its parts, eg data type definitions, functions, macros, variables.
Some vi clones (elvis, vile, and vim) provide several enhancements already. Vim already finds all matches and allow to move to the next or previous match.
The generation of a tags file was usually done with the program "ctags", short for "Create TAGS file". Unfortunately, this program could just be used with the language 'C' - but not for C++ or Java.
So Darren Hiebert wrote another "ctags" program which is now capable of generating a tags file for source code in C++ and Java.
There are some more commands that deals with tags. More about this later.
Every tagname that gets used with a "tag command" is pushed onto a stack, ie it is remembered in a "last in - first out" (LIFO) structure. This allows to reuse the tagnames, eg to jump back to the last used tagname. With Vim this command is '^T'.
Vim uses tags to allow quick access to other helptexts in the helpfiles. One of the many improvements of Vim over Vi is that Vim has commands to show the "tag stack" together with the associated filenames, as well as showing the current tagname.
Example: Add some tags to the tag stack by entering some help commands� eg ":help www" and ":help news". Then enter ":tags" to show the tag stack:
:tags # TO tag FROM line in file 1 1 www 95 tagsearch.txt 2 1 news 50 -current- >Unfortunately this command does not show the name of the current file, but simply "-current-". Yp Note: When jumping back to an older tagname with