disabled when not looking for a tag with a
specific name. This happens when ignoring case and when a regular expression
is used that doesn't start with a fixed string. Tag searching can be a lot
slower then. The former can be avoided by case-fold sorting the tags file.
See 'tagbsearch' for details.
*tag-regexp*
The ":tag" and ":tselect" commands accept a regular expression argument. See
|pattern| for the special characters that can be used.
When the argument starts with '/', it is used as a pattern. If the argument
does not start with '/', it is taken literally, as a full tag name.
Examples: >
:tag main
< jumps to the tag "main" that has the highest priority. >
:tag /^get
< jumps to the tag that starts with "get" and has the highest priority. >
:tag /norm
< lists all the tags that contain "norm", including "id_norm".
When the argument both exists literally, and match when used as a regexp, a
literal match has a higher priority. For example, ":tag /open" matches "open"
before "open_file" and "file_open".
When using a pattern case is ignored. If you want to match case use "\C" in
the pattern.
*tag-!*
If the tag is in the current file this will always work. Otherwise the
performed actions depend on whether the current file was changed, whether a !
is added to the command and on the 'autowrite' and 'winfixbuf' options:
tag in file winfixbuf autowrite ~
current file changed ! option option action ~
-----------------------------------------------------------------------------
yes x x off x goto tag
no no x off x read other file, goto tag
no yes yes off x abandon current file,
read other file, goto tag
no yes no off on write current file,
read other file, goto tag
no yes no off off fail
yes x yes x x goto tag
no no no on x fail
no yes no on x fail
no yes no on on fail
no yes no on off fail
-----------------------------------------------------------------------------
- If the tag is in the current file, the command will always work.
- If the tag is in another file and the current file was not changed, the
other file will be made the current file and read into the buffer.
- If the tag is in another file, the current file was changed and a ! is
added to the command, the changes to the current file are lost, the other
file will be made the current file and read into the buffer.
- If the tag is in another file, the current file was changed and the
'autowrite' option is on, the current file will be written, the other
file will be made the current file and read into the buffer.
- If the tag is in another file, the current file was changed and the
'autowrite' option is off, the command will fail. If you want to save
the changes, use the ":w" command and then use ":tag" without an argument.
This works because the tag is put on 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*