Home Explore Blog CI



neovim

3rd chunk of `runtime/doc/tagsrch.txt`
0cde6b728378cf33f314726c23ea17a6203c50260f8044f40000000100000fa5

deleting/inserting lines, unless this was done by another program (e.g.
another instance of Vim).

For the current file, the "file/text" column shows the text at the position.
An indent is removed and a long line is truncated to fit in the window.

You can jump to previously used tags with several commands.  Some examples:

	":pop" or CTRL-T	to position before previous tag
	{count}CTRL-T		to position before {count} older tag
	":tag"			to newer tag
	":0tag"			to last used tag

The most obvious way to use this is while browsing through the call graph of
a program.  Consider the following call graph:

	main  --->  FuncA  --->  FuncC
	      --->  FuncB

(Explanation: main calls FuncA and FuncB; FuncA calls FuncC).
You can get from main to FuncA by using CTRL-] on the call to FuncA.  Then
you can CTRL-] to get to FuncC.  If you now want to go back to main you can
use CTRL-T twice.  Then you can CTRL-] to FuncB.

If you issue a ":ta {name}" or CTRL-] command, this tag is inserted at the
current position in the stack.  If the stack was full (it can hold up to 20
entries), the oldest entry is deleted and the older entries shift one
position up (their index number is decremented by one).  If the last used
entry was not at the bottom, the entries below the last used one are
deleted.  This means that an old branch in the call graph is lost.  After the
commands explained above the tag stack will look like this:

   # TO tag	FROM line  in file/text
   1  1 main		1  harddisk2:text/vim/test
   2  1 FuncB	       59  harddisk2:text/vim/src/main.c

The |gettagstack()| function returns the tag stack of a specified window. The
|settagstack()| function modifies the tag stack of a window.

							*tagstack-examples*
Write to the tag stack just like `:tag` but with a user-defined
jumper#jump_to_tag function: >
	" Store where we're jumping from before we jump.
	let tag = expand('<cword>')
	let pos = [bufnr()] + getcurpos()[1:]
	let item = {'bufnr': pos[0], 'from': pos, 'tagname': tag}
	if jumper#jump_to_tag(tag)
		" Jump was successful, write previous location to tag stack.
		let winid = win_getid()
		let stack = gettagstack(winid)
		let stack['items'] = [item]
		call settagstack(winid, stack, 't')
	endif
<
Set current index of the tag stack to 4: >
	call settagstack(1005, {'curidx' : 4})
<
Push a new item onto the tag stack: >
	let pos = [bufnr('myfile.txt'), 10, 1, 0]
	let newtag = [{'tagname' : 'mytag', 'from' : pos}]
	call settagstack(2, {'items' : newtag}, 'a')
<
							*E73*
When you try to use the tag stack while it doesn't contain anything you will
get an error message.

==============================================================================
3. Tag match list				*tag-matchlist* *E427* *E428*

When there are several matching tags, these commands can be used to jump
between them.  Note that these commands don't change the tag stack, they keep
the same entry.

							*:ts* *:tselect*
:ts[elect][!] [name]	List the tags that match [name], using the
			information in the tags file(s).
			When [name] is not given, the last tag name from the
			tag stack is used.
			See |tag-!| for [!].
			With a '>' in the first column is indicated which is
			the current position in the list (if there is one).
			[name] can be a regexp pattern, see |tag-regexp|.
			See |tag-priority| for the priorities used in the
			listing.
			Example output:

>
	  # pri kind tag		file
	  1 F	f    mch_delay		os_amiga.c
			mch_delay(msec, ignoreinput)
	> 2 F	f    mch_delay		os_msdos.c
			mch_delay(msec, ignoreinput)
	  3 F	f    mch_delay		os_unix.c
			mch_delay(msec, ignoreinput)
	Type number and <Enter> (empty cancels):
<
			See |tag-priority| for the "pri" column.  Note that
			this depends on the current file, thus using
			":tselect xxx" can produce different results.
			The "kind" column gives the kind of tag, if this was
			included in the tags file.
			The "info" column shows information that could be
			found in the tags file.  It depends on the program
			that produced

Title: Tag Stack Management and Match Lists in Vim
Summary
This section describes how the tag stack is managed in Vim, including how new tags are added, how the stack behaves when full, and how the `gettagstack()` and `settagstack()` functions can be used to interact with it. It provides examples of using these functions to write to, set the index of, and push new items onto the tag stack. It also discusses tag match lists, which appear when multiple tags match a given name. The `:tselect` command is detailed, along with the information presented in the match list, such as priority, kind, file, and additional information. It also explains that the tag-priority depends on the current file.