the stack anyway. If you want to lose
the changes you can use the ":tag!" command.
- If the tag is in another file and the window includes 'winfixbuf', the
command will fail. If the tag is in the same file then it may succeed.
*tag-security*
Note that Vim forbids some commands, for security reasons. This works like
using the 'secure' option for exrc/vimrc files in the current directory. See
|trojan-horse| and |sandbox|.
When the {tagaddress} changes a buffer, you will get a warning message:
"WARNING: tag command changed a buffer!!!"
In a future version changing the buffer will be impossible. All this for
security reasons: Somebody might hide a nasty command in the tags file, which
would otherwise go unnoticed. Example: >
:$d|/tag-function-name/
In Vi the ":tag" command sets the last search pattern when the tag is searched
for. In Vim this is not done, the previous search pattern is still remembered,
unless the 't' flag is present in 'cpoptions'.
*tags-option*
The 'tags' option is a list of file names. Each of these files is searched
for the tag. This can be used to use a different tags file than the default
file "tags". It can also be used to access a common tags file.
The next file in the list is not used when:
- A matching static tag for the current buffer has been found.
- A matching global tag has been found.
This also depends on whether case is ignored. Case is ignored when:
- 'tagcase' is "followic" and 'ignorecase' is set
- 'tagcase' is "ignore"
- 'tagcase' is "smart" and the pattern only contains lower case
characters.
- 'tagcase' is "followscs" and 'smartcase' is set and the pattern only
contains lower case characters.
If case is not ignored, and the tags file only has a match without matching
case, the next tags file is searched for a match with matching case. If no
tag with matching case is found, the first match without matching case is
used. If case is ignored, and a matching global tag with or without matching
case is found, this one is used, no further tags files are searched.
When a tag file name starts with "./", the '.' is replaced with the path of
the current file. This makes it possible to use a tags file in the directory
where the current file is (no matter what the current directory is). The idea
of using "./" is that you can define which tag file is searched first: In the
current directory ("tags,./tags") or in the directory of the current file
("./tags,tags").
For example: >
:set tags=./tags,tags,/home/user/commontags
In this example the tag will first be searched for in the file "tags" in the
directory where the current file is. Next the "tags" file in the current
directory. If it is not found there, then the file "/home/user/commontags"
will be searched for the tag.
This can be switched off by including the 'd' flag in 'cpoptions', to make
it Vi compatible. "./tags" will then be the tags file in the current
directory, instead of the tags file in the directory where the current file
is.
Instead of the comma a space may be used. Then a backslash is required for
the space to be included in the string option: >
:set tags=tags\ /home/user/commontags
To include a space in a file name use three backslashes. To include a comma
in a file name use two backslashes. For example, use: >
:set tags=tag\\\ file,/home/user/common\\,tags
for the files "tag file" and "/home/user/common,tags". The 'tags' option will
have the value "tag\ file,/home/user/common\,tags".
If the 'tagrelative' option is on (which is the default) and using a tag file
in another directory, file names in that tag file are relative to the
directory where the tag file is.
==============================================================================
5. Tags file format *tags-file-format* *E431*
*ctags*
A tags file can be created with an external command, for example "ctags". It
will contain a tag for each function. Some versions of "ctags" will also make
a tag for each "#defined"