neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

tagsrch.txt (40972B)


      1 *tagsrch.txt*   Nvim
      2 
      3 
      4 	  VIM REFERENCE MANUAL	  by Bram Moolenaar
      5 
      6 
      7 Tags and special searches				*tags-and-searches*
      8 
      9 See section |29.1| of the user manual for an introduction.
     10 
     11                                      Type |gO| to see the table of contents.
     12 
     13 ==============================================================================
     14 1. Jump to a tag					*tag-commands*
     15 
     16 						*tag* *tags*
     17 A tag is an identifier that appears in a "tags" file.  It is a sort of label
     18 that can be jumped to.  For example: In C programs each function name can be
     19 used as a tag.  The "tags" file has to be generated by a program like ctags,
     20 before the tag commands can be used.
     21 
     22 With the ":tag" command the cursor will be positioned on the tag.  With the
     23 CTRL-] command, the keyword on which the cursor is standing is used as the
     24 tag.  If the cursor is not on a keyword, the first keyword to the right of the
     25 cursor is used.
     26 
     27 The ":tag" command works very well for C programs.  If you see a call to a
     28 function and wonder what that function does, position the cursor inside of the
     29 function name and hit CTRL-].  This will bring you to the function definition.
     30 An easy way back is with the CTRL-T command.  Also read about the tag stack
     31 below.
     32 
     33 					*:ta* *:tag* *E426* *E429*
     34 :[count]ta[g][!] {name}
     35 		Jump to the definition of {name}, using the
     36 		information in the tags file(s).  Put {name} in the
     37 		tag stack.  See |tag-!| for [!].
     38 		{name} can be a regexp pattern, see |tag-regexp|.
     39 		When there are several matching tags for {name}, jump
     40 		to the [count] one.  When [count] is omitted the
     41 		first one is jumped to.  See |tag-matchlist| for
     42 		jumping to other matching tags.
     43 
     44 g<LeftMouse>						*g<LeftMouse>*
     45 <C-LeftMouse>					*<C-LeftMouse>* *CTRL-]*
     46 CTRL-]			Jump to the definition of the keyword under the
     47 		cursor.  Same as ":tag {name}", where {name} is the
     48 		keyword under or after cursor.
     49 		When there are several matching tags for {name}, jump
     50 		to the [count] one.  When no [count] is given the
     51 		first one is jumped to.  See |tag-matchlist| for
     52 		jumping to other matching tags.
     53 
     54 						*v_CTRL-]*
     55 {Visual}CTRL-]		Same as ":tag {name}", where {name} is the text that
     56 		is highlighted.
     57 
     58 						*telnet-CTRL-]*
     59 CTRL-] is the default telnet escape key.  When you type CTRL-] to jump to a
     60 tag, you will get the telnet prompt instead.  Most versions of telnet allow
     61 changing or disabling the default escape key.  See the telnet man page.  You
     62 can `telnet -E {Hostname}` to disable the escape character, or
     63 `telnet -e {EscapeCharacter} {Hostname}` to specify another escape character.
     64 If possible, try to use "ssh" instead of "telnet" to avoid this problem.
     65 
     66 						*tag-priority*
     67 When there are multiple matches for a tag, this priority is used:
     68 1. "FSC"  A full matching static tag for the current file.
     69 2. "F C"  A full matching global tag for the current file.
     70 3. "F  "  A full matching global tag for another file.
     71 4. "FS "  A full matching static tag for another file.
     72 5. " SC"  An ignore-case matching static tag for the current file.
     73 6. "  C"  An ignore-case matching global tag for the current file.
     74 7. "   "  An ignore-case matching global tag for another file.
     75 8. " S "  An ignore-case matching static tag for another file.
     76 
     77 Note that when the current file changes, the priority list is mostly not
     78 changed, to avoid confusion when using ":tnext".  It is changed when using
     79 ":tag {name}".
     80 
     81 The ignore-case matches are not found for a ":tag" command when:
     82 - 'tagcase' is "followic" and the 'ignorecase' option is off
     83 - 'tagcase' is "followscs" and the 'ignorecase' option is off and the
     84  'smartcase' option is off or the pattern contains an upper case character.
     85 - 'tagcase' is "match"
     86 - 'tagcase' is "smart" and the pattern contains an upper case character.
     87 
     88 The ignore-case matches are found when:
     89 - a pattern is used (starting with a "/")
     90 - for ":tselect"
     91 - when 'tagcase' is "followic" and 'ignorecase' is on
     92 - when 'tagcase' is "followscs" and 'ignorecase' is on or the 'smartcase'
     93  option is on and the pattern does not contain an upper case character
     94 - when 'tagcase' is "ignore"
     95 - when 'tagcase' is "smart" and the pattern does not contain an upper case
     96  character
     97 
     98 Note that using ignore-case tag searching disables binary searching in the
     99 tags file, which causes a slowdown.  This can be avoided by fold-case sorting
    100 the tag file.  See the 'tagbsearch' option for an explanation.
    101 
    102 ==============================================================================
    103 2. Tag stack				*tag-stack* *tagstack* *E425*
    104 
    105 On the tag stack is remembered which tags you jumped to, and from where.
    106 Tags are only pushed onto the stack when the 'tagstack' option is set.
    107 
    108 g<RightMouse>						*g<RightMouse>*
    109 <C-RightMouse>					*<C-RightMouse>* *CTRL-T*
    110 CTRL-T			Jump to [count] older entry in the tag stack
    111 		(default 1).
    112 
    113 					*:po* *:pop* *E555* *E556*
    114 :[count]po[p][!]	Jump to [count] older entry in tag stack (default 1).
    115 		See |tag-!| for [!].
    116 
    117 :[count]ta[g][!]	Jump to [count] newer entry in tag stack (default 1).
    118 		See |tag-!| for [!].
    119 
    120 						*:tags*
    121 :tags			Show the contents of the tag stack.  The active
    122 		entry is marked with a '>'.
    123 
    124 The output of ":tags" looks like this:
    125 
    126   # TO tag      FROM line  in file/text
    127   1  1 main		 1  harddisk2:text/vim/test
    128 > 2  2 FuncA		58  i = FuncA(10);
    129   3  1 FuncC	       357  harddisk2:text/vim/src/amiga.c
    130 
    131 This list shows the tags that you jumped to and the cursor position before
    132 that jump.  The older tags are at the top, the newer at the bottom.
    133 
    134 The '>' points to the active entry.  This is the tag that will be used by the
    135 next ":tag" command.  The CTRL-T and ":pop" command will use the position
    136 above the active entry.
    137 
    138 Below the "TO" is the number of the current match in the match list.  Note
    139 that this doesn't change when using ":pop" or ":tag".
    140 
    141 The line number and file name are remembered to be able to get back to where
    142 you were before the tag command.  The line number will be correct, also when
    143 deleting/inserting lines, unless this was done by another program (e.g.
    144 another instance of Vim).
    145 
    146 For the current file, the "file/text" column shows the text at the position.
    147 An indent is removed and a long line is truncated to fit in the window.
    148 
    149 You can jump to previously used tags with several commands.  Some examples:
    150 
    151 ":pop" or CTRL-T	to position before previous tag
    152 {count}CTRL-T		to position before {count} older tag
    153 ":tag"			to newer tag
    154 ":0tag"			to last used tag
    155 
    156 The most obvious way to use this is while browsing through the call graph of
    157 a program.  Consider the following call graph:
    158 
    159 main  --->  FuncA  --->  FuncC
    160       --->  FuncB
    161 
    162 (Explanation: main calls FuncA and FuncB; FuncA calls FuncC).
    163 You can get from main to FuncA by using CTRL-] on the call to FuncA.  Then
    164 you can CTRL-] to get to FuncC.  If you now want to go back to main you can
    165 use CTRL-T twice.  Then you can CTRL-] to FuncB.
    166 
    167 If you issue a ":ta {name}" or CTRL-] command, this tag is inserted at the
    168 current position in the stack.  If the stack was full (it can hold up to 20
    169 entries), the oldest entry is deleted and the older entries shift one
    170 position up (their index number is decremented by one).  If the last used
    171 entry was not at the bottom, the entries below the last used one are
    172 deleted.  This means that an old branch in the call graph is lost.  After the
    173 commands explained above the tag stack will look like this:
    174 
    175   # TO tag	FROM line  in file/text
    176   1  1 main		1  harddisk2:text/vim/test
    177   2  1 FuncB	       59  harddisk2:text/vim/src/main.c
    178 
    179 The |gettagstack()| function returns the tag stack of a specified window.  The
    180 |settagstack()| function modifies the tag stack of a window.
    181 
    182 						*tagstack-examples*
    183 Write to the tag stack just like `:tag` but with a user-defined
    184 jumper#jump_to_tag function: >
    185 " Store where we're jumping from before we jump.
    186 let tag = expand('<cword>')
    187 let pos = [bufnr()] + getcurpos()[1:]
    188 let item = {'bufnr': pos[0], 'from': pos, 'tagname': tag}
    189 if jumper#jump_to_tag(tag)
    190 	" Jump was successful, write previous location to tag stack.
    191 	let winid = win_getid()
    192 	let stack = gettagstack(winid)
    193 	let stack['items'] = [item]
    194 	call settagstack(winid, stack, 't')
    195 endif
    196 <
    197 Set current index of the tag stack to 4: >
    198 call settagstack(1005, {'curidx' : 4})
    199 <
    200 Push a new item onto the tag stack: >
    201 let pos = [bufnr('myfile.txt'), 10, 1, 0]
    202 let newtag = [{'tagname' : 'mytag', 'from' : pos}]
    203 call settagstack(2, {'items' : newtag}, 'a')
    204 <
    205 						*E73*
    206 When you try to use the tag stack while it doesn't contain anything you will
    207 get an error message.
    208 
    209 ==============================================================================
    210 3. Tag match list				*tag-matchlist* *E427* *E428*
    211 
    212 When there are several matching tags, these commands can be used to jump
    213 between them.  Note that these commands don't change the tag stack, they keep
    214 the same entry.
    215 
    216 						*:ts* *:tselect*
    217 :ts[elect][!] [name]	List the tags that match [name], using the
    218 		information in the tags file(s).
    219 		When [name] is not given, the last tag name from the
    220 		tag stack is used.
    221 		See |tag-!| for [!].
    222 		With a '>' in the first column is indicated which is
    223 		the current position in the list (if there is one).
    224 		[name] can be a regexp pattern, see |tag-regexp|.
    225 		See |tag-priority| for the priorities used in the
    226 		listing.
    227 		Example output:
    228 
    229 >
    230   # pri kind tag		file
    231   1 F	f    mch_delay		os_amiga.c
    232 		mch_delay(msec, ignoreinput)
    233 > 2 F	f    mch_delay		os_msdos.c
    234 		mch_delay(msec, ignoreinput)
    235   3 F	f    mch_delay		os_unix.c
    236 		mch_delay(msec, ignoreinput)
    237 Type number and <Enter> (empty cancels):
    238 <
    239 		See |tag-priority| for the "pri" column.  Note that
    240 		this depends on the current file, thus using
    241 		":tselect xxx" can produce different results.
    242 		The "kind" column gives the kind of tag, if this was
    243 		included in the tags file.
    244 		The "info" column shows information that could be
    245 		found in the tags file.  It depends on the program
    246 		that produced the tags file.
    247 		When the list is long, you may get the |more-prompt|.
    248 		If you already see the tag you want to use, you can
    249 		type 'q' and enter the number.
    250 
    251 						*:sts* *:stselect*
    252 :sts[elect][!] [name]	Does ":tselect[!] [name]" and splits the window for
    253 		the selected tag.
    254 
    255 						*g]*
    256 g]			Like CTRL-], but use ":tselect" instead of ":tag".
    257 
    258 						*v_g]*
    259 {Visual}g]		Same as "g]", but use the highlighted text as the
    260 		identifier.
    261 
    262 						*:tj* *:tjump*
    263 :tj[ump][!] [name]	Like ":tselect", but jump to the tag directly when
    264 		there is only one match.
    265 
    266 						*:stj* *:stjump*
    267 :stj[ump][!] [name]	Does ":tjump[!] [name]" and splits the window for the
    268 		selected tag.
    269 
    270 						*g_CTRL-]*
    271 g CTRL-]		Like CTRL-], but use ":tjump" instead of ":tag".
    272 
    273 						*v_g_CTRL-]*
    274 {Visual}g CTRL-]	Same as "g CTRL-]", but use the highlighted text as
    275 		the identifier.
    276 
    277 						*:tn* *:tnext*
    278 :[count]tn[ext][!]	Jump to [count] next matching tag (default 1).  See
    279 		|tag-!| for [!].
    280 
    281 							*]t*
    282 ]t			Mapped to |:tnext|. |default-mappings|
    283 
    284 						*:tp* *:tprevious*
    285 :[count]tp[revious][!]	Jump to [count] previous matching tag (default 1).
    286 		See |tag-!| for [!].
    287 
    288 							*[t*
    289 [t			Mapped to |:tprevious|. |default-mappings|
    290 
    291 						*:tN* *:tNext*
    292 :[count]tN[ext][!]	Same as ":tprevious".
    293 
    294 						*:tr* *:trewind*
    295 :[count]tr[ewind][!]	Jump to first matching tag.  If [count] is given, jump
    296 		to [count]th matching tag.  See |tag-!| for [!].
    297 
    298 							*[T*
    299 [T			Mapped to |:trewind|. |default-mappings|
    300 
    301 						*:tf* *:tfirst*
    302 :[count]tf[irst][!]	Same as ":trewind".
    303 
    304 						*:tl* *:tlast*
    305 :tl[ast][!]		Jump to last matching tag.  See |tag-!| for [!].
    306 
    307 							*]T*
    308 ]T			Mapped to |:tlast|. |default-mappings|
    309 
    310 						*:lt* *:ltag*
    311 :lt[ag][!] [name]	Jump to tag [name] and add the matching tags to a new
    312 		location list for the current window.  [name] can be
    313 		a regexp pattern, see |tag-regexp|.  When [name] is
    314 		not given, the last tag name from the tag stack is
    315 		used.  The search pattern to locate the tag line is
    316 		prefixed with "\V" to escape all the special
    317 		characters (very nomagic).  The location list showing
    318 		the matching tags is independent of the tag stack.
    319 		See |tag-!| for [!].
    320 
    321 When there is no other message, Vim shows which matching tag has been jumped
    322 to, and the number of matching tags: >
    323 tag 1 of 3 or more
    324 The " or more" is used to indicate that Vim didn't try all the tags files yet.
    325 When using ":tnext" a few times, or with ":tlast", more matches may be found.
    326 
    327 When you didn't see this message because of some other message, or you just
    328 want to know where you are, this command will show it again (and jump to the
    329 same tag as last time): >
    330 :0tn
    331 <
    332 						*tag-skip-file*
    333 When a matching tag is found for which the file doesn't exist, this match is
    334 skipped and the next matching tag is used.  Vim reports this, to notify you of
    335 missing files.  When the end of the list of matches has been reached, an error
    336 message is given.
    337 
    338 						*tag-preview*
    339 The tag match list can also be used in the preview window.  The commands are
    340 the same as above, with a "p" prepended.
    341 
    342 						*:pts* *:ptselect*
    343 :pts[elect][!] [name]	Does ":tselect[!] [name]" and shows the new tag in a
    344 		"Preview" window.  See |:ptag| for more info.
    345 
    346 						*:ptj* *:ptjump*
    347 :ptj[ump][!] [name]	Does ":tjump[!] [name]" and shows the new tag in a
    348 		"Preview" window.  See |:ptag| for more info.
    349 
    350 						*:ptn* *:ptnext*
    351 :[count]ptn[ext][!]	":tnext" in the preview window.  See |:ptag|.
    352 
    353 							*]_CTRL-T*
    354 ]_CTRL-T		Mapped to |:ptnext|. |default-mappings|
    355 
    356 						*:ptp* *:ptprevious*
    357 :[count]ptp[revious][!]	":tprevious" in the preview window.  See |:ptag|.
    358 
    359 							*[_CTRL-T*
    360 [_CTRL-T		Mapped to |:ptprevious|. |default-mappings|
    361 
    362 						*:ptN* *:ptNext*
    363 :[count]ptN[ext][!]	Same as ":ptprevious".
    364 
    365 						*:ptr* *:ptrewind*
    366 :[count]ptr[ewind][!]	":trewind" in the preview window.  See |:ptag|.
    367 
    368 						*:ptf* *:ptfirst*
    369 :[count]ptf[irst][!]	Same as ":ptrewind".
    370 
    371 						*:ptl* *:ptlast*
    372 :ptl[ast][!]		":tlast" in the preview window.  See |:ptag|.
    373 
    374 ==============================================================================
    375 4. Tags details						*tag-details*
    376 
    377 						*static-tag*
    378 A static tag is a tag that is defined for a specific file.  In a C program
    379 this could be a static function.
    380 
    381 In Vi jumping to a tag sets the current search pattern.  This means that the
    382 "n" command after jumping to a tag does not search for the same pattern that
    383 it did before jumping to the tag.  Vim does not do this as we consider it to
    384 be a bug.  If you really want the old Vi behavior, set the 't' flag in
    385 'cpoptions'.
    386 
    387 						*tag-binary-search*
    388 Vim uses binary searching in the tags file to find the desired tag quickly.
    389 But this only works if the tags file was sorted on ASCII byte value.
    390 Therefore, if no match was found, another try is done with a linear search.
    391 If you only want the linear search, reset the 'tagbsearch' option.  Or better:
    392 Sort the tags file!
    393 
    394 Note that the binary searching is disabled when not looking for a tag with a
    395 specific name.  This happens when ignoring case and when a regular expression
    396 is used that doesn't start with a fixed string.  Tag searching can be a lot
    397 slower then.  The former can be avoided by case-fold sorting the tags file.
    398 See 'tagbsearch' for details.
    399 
    400 						*tag-regexp*
    401 The ":tag" and ":tselect" commands accept a regular expression argument.  See
    402 |pattern| for the special characters that can be used.
    403 When the argument starts with '/', it is used as a pattern.  If the argument
    404 does not start with '/', it is taken literally, as a full tag name.
    405 Examples: >
    406    :tag main
    407 <	jumps to the tag "main" that has the highest priority. >
    408    :tag /^get
    409 <	jumps to the tag that starts with "get" and has the highest priority. >
    410    :tag /norm
    411 <	lists all the tags that contain "norm", including "id_norm".
    412 When the argument both exists literally, and match when used as a regexp, a
    413 literal match has a higher priority.  For example, ":tag /open" matches "open"
    414 before "open_file" and "file_open".
    415 When using a pattern case is ignored.  If you want to match case use "\C" in
    416 the pattern.
    417 
    418 						*tag-!*
    419 If the tag is in the current file this will always work.  Otherwise the
    420 performed actions depend on whether the current file was changed, whether a !
    421 is added to the command and on the 'autowrite' and 'winfixbuf' options:
    422 
    423  tag in       file	    winfixbuf	autowrite		~
    424 current file  changed	!   option	option	      action	~
    425 -----------------------------------------------------------------------------
    426    yes		x	x      off	  x	    goto tag
    427    no		no	x      off	  x	    read other file, goto tag
    428    no		yes	yes    off	  x	    abandon current file,
    429 					    read other file, goto tag
    430    no		yes	no     off	  on	    write current file,
    431 					    read other file, goto tag
    432    no		yes	no     off	  off	    fail
    433    yes		x	yes    x	  x	    goto tag
    434    no		no	no     on	  x	    fail
    435    no		yes	no     on	  x	    fail
    436    no		yes	no     on	  on	    fail
    437    no		yes	no     on	  off	    fail
    438 -----------------------------------------------------------------------------
    439 
    440 - If the tag is in the current file, the command will always work.
    441 - If the tag is in another file and the current file was not changed, the
    442  other file will be made the current file and read into the buffer.
    443 - If the tag is in another file, the current file was changed and a ! is
    444  added to the command, the changes to the current file are lost, the other
    445  file will be made the current file and read into the buffer.
    446 - If the tag is in another file, the current file was changed and the
    447  'autowrite' option is on, the current file will be written, the other
    448  file will be made the current file and read into the buffer.
    449 - If the tag is in another file, the current file was changed and the
    450  'autowrite' option is off, the command will fail.  If you want to save
    451  the changes, use the ":w" command and then use ":tag" without an argument.
    452  This works because the tag is put on the stack anyway.  If you want to lose
    453  the changes you can use the ":tag!" command.
    454 - If the tag is in another file and the window includes 'winfixbuf', the
    455  command will fail.  If the tag is in the same file then it may succeed.
    456 
    457 						*tag-security*
    458 Note that Vim forbids some commands, for security reasons.  This works like
    459 using the 'secure' option for exrc/vimrc files in the current directory.  See
    460 |trojan-horse| and |sandbox|.
    461 When the {tagaddress} changes a buffer, you will get a warning message:
    462 "WARNING: tag command changed a buffer!!!"
    463 In a future version changing the buffer will be impossible.  All this for
    464 security reasons: Somebody might hide a nasty command in the tags file, which
    465 would otherwise go unnoticed.  Example: >
    466 :$d|/tag-function-name/
    467 
    468 In Vi the ":tag" command sets the last search pattern when the tag is searched
    469 for.  In Vim this is not done, the previous search pattern is still
    470 remembered, unless the 't' flag is present in 'cpoptions'.
    471 
    472 						*tags-option*
    473 The 'tags' option is a list of file names.  Each of these files is searched
    474 for the tag.  This can be used to use a different tags file than the default
    475 file "tags".  It can also be used to access a common tags file.
    476 
    477 The next file in the list is not used when:
    478 - A matching static tag for the current buffer has been found.
    479 - A matching global tag has been found.
    480 This also depends on whether case is ignored.  Case is ignored when:
    481 - 'tagcase' is "followic" and 'ignorecase' is set
    482 - 'tagcase' is "ignore"
    483 - 'tagcase' is "smart" and the pattern only contains lower case
    484  characters.
    485 - 'tagcase' is "followscs" and 'smartcase' is set and the pattern only
    486  contains lower case characters.
    487 If case is not ignored, and the tags file only has a match without matching
    488 case, the next tags file is searched for a match with matching case.  If no
    489 tag with matching case is found, the first match without matching case is
    490 used.  If case is ignored, and a matching global tag with or without matching
    491 case is found, this one is used, no further tags files are searched.
    492 
    493 When a tag file name starts with "./", the '.' is replaced with the path of
    494 the current file.  This makes it possible to use a tags file in the directory
    495 where the current file is (no matter what the current directory is).  The idea
    496 of using "./" is that you can define which tag file is searched first: In the
    497 current directory ("tags,./tags") or in the directory of the current file
    498 ("./tags,tags").
    499 
    500 For example: >
    501 :set tags=./tags,tags,/home/user/commontags
    502 
    503 In this example the tag will first be searched for in the file "tags" in the
    504 directory where the current file is.  Next the "tags" file in the current
    505 directory.  If it is not found there, then the file "/home/user/commontags"
    506 will be searched for the tag.
    507 
    508 This can be switched off by including the 'd' flag in 'cpoptions', to make
    509 it Vi compatible.  "./tags" will then be the tags file in the current
    510 directory, instead of the tags file in the directory where the current file
    511 is.
    512 
    513 Instead of the comma a space may be used.  Then a backslash is required for
    514 the space to be included in the string option: >
    515 :set tags=tags\ /home/user/commontags
    516 
    517 To include a space in a file name use three backslashes.  To include a comma
    518 in a file name use two backslashes.  For example, use: >
    519 :set tags=tag\\\ file,/home/user/common\\,tags
    520 
    521 for the files "tag file" and "/home/user/common,tags".  The 'tags' option will
    522 have the value "tag\ file,/home/user/common\,tags".
    523 
    524 If the 'tagrelative' option is on (which is the default) and using a tag file
    525 in another directory, file names in that tag file are relative to the
    526 directory where the tag file is.
    527 
    528 ==============================================================================
    529 5. Tags file format				*tags-file-format* *E431*
    530 
    531 					*ctags*
    532 A tags file can be created with an external command, for example "ctags".  It
    533 will contain a tag for each function.  Some versions of "ctags" will also make
    534 a tag for each "#defined" macro, typedefs, enums, etc.
    535 
    536 Some programs that generate tags files:
    537 ctags			As found on most Unix systems.  Only supports C.  Only
    538 		does the basic work.
    539 universal ctags		A maintained version of ctags based on exuberant
    540 		ctags.  See https://ctags.io.
    541 						*Exuberant_ctags*
    542 exuberant ctags		Works for C, C++, Java, Fortran, Eiffel and others.
    543 		See https://ctags.sourceforge.net. No new version
    544 		since 2009.
    545 |:helptags|		For Vim's |help| files
    546 ptags.py		For Python, in Python.  Found in your Python source
    547 		directory at Tools/scripts/ptags.py.
    548 ptags			For Perl, in Perl.  It can be found at
    549 		https://metacpan.org/pod/Vim::Tag
    550 
    551 
    552 The lines in the tags file must have one of these two formats:
    553 
    554 1.  {tagname}		{TAB} {tagfile} {TAB} {tagaddress}
    555 2.  {tagname}		{TAB} {tagfile} {TAB} {tagaddress} {term} {field} ..
    556 
    557 Previously an old format was supported, see |tag-old-static|.
    558 
    559 The first format is a normal tag, which is completely compatible with Vi.  It
    560 is the only format produced by traditional ctags implementations.  This is
    561 often used for functions that are global, also referenced in other files.
    562 
    563 The lines in the tags file can end in <NL> or <CR><NL>.  On the Macintosh <CR>
    564 also works.  The <CR> and <NL> characters can never appear inside a line.
    565 
    566 The second format is new.  It includes additional information in optional
    567 fields at the end of each line.  It is backwards compatible with Vi.  It is
    568 only supported by new versions of ctags (such as Universal ctags or Exuberant
    569 ctags).
    570 
    571 {tagname}	The identifier.  Normally the name of a function, but it can
    572 	be any identifier.  It cannot contain a <Tab>.
    573 {TAB}		One <Tab> character.  Note: previous versions allowed any
    574 	white space here.  This has been abandoned to allow spaces in
    575 	{tagfile}.
    576 {tagfile}	The file that contains the definition of {tagname}.  It can
    577 	have an absolute or relative path.  It may contain environment
    578 	variables and wildcards (although the use of wildcards is
    579 	doubtful).  It cannot contain a <Tab>.
    580 {tagaddress}	The Ex command that positions the cursor on the tag.  It can
    581 	be any Ex command, although restrictions apply (see
    582 	|tag-security|).  Posix only allows line numbers and search
    583 	commands, which are mostly used.
    584 {term}		;" The two characters semicolon and double quote.  This is
    585 	interpreted by Vi as the start of a comment, which makes the
    586 	following be ignored.  This is for backwards compatibility
    587 	with Vi, it ignores the following fields.  Example: >
    588 		APP	file	/^static int APP;$/;"	v
    589 <		When {tagaddress} is not a line number or search pattern, then
    590 	{term} must be `|;"`.  Here the bar ends the command (excluding
    591 	the bar) and `;"` is used to have Vi ignore the rest of the
    592 	line.  Example: >
    593 		APP	file.c	call cursor(3, 4)|;"	v
    594 
    595 {field} ..	A list of optional fields.  Each field has the form:
    596 
    597 		<Tab>{fieldname}:{value}
    598 
    599 	The {fieldname} identifies the field, and can only contain
    600 	alphabetical characters [a-zA-Z].
    601 	The {value} is any string, but cannot contain a <Tab>.
    602 	These characters are special:
    603 		"\t" stands for a <Tab>
    604 		"\r" stands for a <CR>
    605 		"\n" stands for a <NL>
    606 		"\\" stands for a single '\' character
    607 
    608 	There is one field that doesn't have a ':'.  This is the kind
    609 	of the tag.  It is handled like it was preceded with "kind:".
    610 	In the above example, this was "kind:v" (typically variable).
    611 	See the documentation of ctags for the kinds it produces, with
    612 	ctags you can use `ctags --list-kinds` .
    613 
    614 	The only other field currently recognized by Vim is "file:"
    615 	(with an empty value).  It is used for a static tag.
    616 
    617 
    618 The first lines in the tags file can contain lines that start with
    619 !_TAG_
    620 These are sorted to the first lines, only rare tags that start with "!" can
    621 sort to before them.  Vim recognizes two items.  The first one is the line
    622 that indicates if the file was sorted.  When this line is found, Vim uses
    623 binary searching for the tags file:
    624 !_TAG_FILE_SORTED<Tab>1<Tab>{anything} ~
    625 
    626 A tag file may be case-fold sorted to avoid a linear search when case is
    627 ignored.  (Case is ignored when 'ignorecase' is set and 'tagcase' is
    628 "followic", or when 'tagcase' is "ignore".)  See 'tagbsearch' for details.
    629 The value '2' should be used then:
    630 !_TAG_FILE_SORTED<Tab>2<Tab>{anything} ~
    631 
    632 The other tag that Vim recognizes is the encoding of the tags file:
    633 !_TAG_FILE_ENCODING<Tab>utf-8<Tab>{anything} ~
    634 Here "utf-8" is the encoding used for the tags.  Vim will then convert the tag
    635 being searched for from 'encoding' to the encoding of the tags file.  And when
    636 listing tags the reverse happens.  When the conversion fails the unconverted
    637 tag is used.
    638 
    639 						*tag-search*
    640 The command can be any Ex command, but often it is a search command.
    641 Examples:
    642 tag1	file1	/^main(argc, argv)/ ~
    643 tag2	file2	108 ~
    644 
    645 The command is always executed with 'magic' not set.  The only special
    646 characters in a search pattern are "^" (begin-of-line) and "$" (<EOL>).
    647 See |pattern|.  Note that you must put a backslash before each backslash in
    648 the search text.  This is for backwards compatibility with Vi.
    649 
    650 						*E434* *E435*
    651 If the command is a normal search command (it starts and ends with "/" or
    652 "?"), some special handling is done:
    653 - Searching starts on line 1 of the file.
    654  The direction of the search is forward for "/", backward for "?".
    655  Note that 'wrapscan' does not matter, the whole file is always searched.
    656 - If the search fails, another try is done ignoring case.  If that fails too,
    657  a search is done for: >
    658 "^tagname[ \t]*("
    659 <  (the tag with '^' prepended and "[ \t]*(" appended).  When using function
    660  names, this will find the function name when it is in column 0.  This will
    661  help when the arguments to the function have changed since the tags file was
    662  made.  If this search also fails another search is done with: >
    663 "^[#a-zA-Z_].*\<tagname[ \t]*("
    664 <  This means: A line starting with '#' or an identifier and containing the tag
    665  followed by white space and a '('.  This will find macro names and function
    666  names with a type prepended.
    667 
    668 
    669 						*tag-old-static*
    670 Until March 2019 (patch 8.1.1092) an outdated format was supported:
    671    {tagfile}:{tagname} {TAB} {tagfile} {TAB} {tagaddress}
    672 
    673 This format is for a static tag only.  It is obsolete now, replaced by
    674 the second format.  It is only supported by Elvis 1.x, older Vim versions and
    675 a few versions of ctags.  A static tag is often used for functions that are
    676 local, only referenced in the file {tagfile}.  Note that for the static tag,
    677 the two occurrences of {tagfile} must be exactly the same.  Also see
    678 |tags-option| below, for how static tags are used.
    679 
    680 The support was removed, since when you can update to the new Vim version you
    681 should also be able to update ctags to one that supports the second format.
    682 
    683 ==============================================================================
    684 6. Include file searches		*include-search* *definition-search*
    685 						*E387* *E388* *E389*
    686 
    687 These commands look for a string in the current file and in all encountered
    688 included files (recursively).  This can be used to find the definition of a
    689 variable, function or macro.  If you only want to search in the current
    690 buffer, use the commands listed at |pattern-searches|.
    691 
    692 When a line is encountered that includes another file, that file is searched
    693 before continuing in the current buffer.  Files included by included files are
    694 also searched.  When an include file could not be found it is silently
    695 ignored.  Use the |:checkpath| command to discover which files could not be
    696 found, possibly your 'path' option is not set up correctly.  Note: the
    697 included file is searched, not a buffer that may be editing that file.  Only
    698 for the current file the lines in the buffer are used.
    699 
    700 The string can be any keyword or a defined macro.  For the keyword any match
    701 will be found.  For defined macros only lines that match with the 'define'
    702 option will be found.  The default is "^#\s*define", which is for C programs.
    703 For other languages you probably want to change this.  See 'define' for an
    704 example for C++.  The string cannot contain an end-of-line, only matches
    705 within a line are found.
    706 
    707 When a match is found for a defined macro, the displaying of lines continues
    708 with the next line when a line ends in a backslash.
    709 
    710 The commands that start with "[" start searching from the start of the current
    711 file.  The commands that start with "]" start at the current cursor position.
    712 
    713 The 'include' option is used to define a line that includes another file.  The
    714 default is "\^#\s*include", which is for C programs.  Note: Vim does not
    715 recognize C syntax, if the 'include' option matches a line inside
    716 "#ifdef/#endif" or inside a comment, it is searched anyway.  The 'isfname'
    717 option is used to recognize the file name that comes after the matched
    718 pattern.
    719 
    720 The 'path' option is used to find the directory for the include files that
    721 do not have an absolute path.
    722 
    723 The 'comments' option is used for the commands that display a single line or
    724 jump to a line.  It defines patterns that may start a comment.  Those lines
    725 are ignored for the search, unless [!] is used.  One exception: When the line
    726 matches the pattern `"^# *define"` it is not considered to be a comment.
    727 
    728 If you want to list matches, and then select one to jump to, you could use a
    729 mapping to do that for you.  Here is an example: >
    730 
    731  :map <F4> [I:let nr = input("Which one: ")<Bar>exe "normal " .. nr .. "[\t"<CR>
    732 <
    733 						*[i*
    734 [i			Display the first line that contains the keyword
    735 		under the cursor.  The search starts at the beginning
    736 		of the file.  Lines that look like a comment are
    737 		ignored (see 'comments' option).  If a count is given,
    738 		the count'th matching line is displayed, and comment
    739 		lines are not ignored.
    740 
    741 						*]i*
    742 ]i			like "[i", but start at the current cursor position.
    743 
    744 						*:is* *:isearch*
    745 :[range]is[earch][!] [count] [/]pattern[/]
    746 		Like "[i"  and "]i", but search in [range] lines
    747 		(default: whole file).
    748 		See |:search-args| for [/] and [!].
    749 
    750 						*[I*
    751 [I			Display all lines that contain the keyword under the
    752 		cursor.  Filenames and line numbers are displayed
    753 		for the found lines.  The search starts at the
    754 		beginning of the file.
    755 
    756 						*]I*
    757 ]I			like "[I", but start at the current cursor position.
    758 
    759 						*:il* *:ilist*
    760 :[range]il[ist][!] [/]pattern[/]
    761 		Like "[I" and "]I", but search in [range] lines
    762 		(default: whole file).
    763 		See |:search-args| for [/] and [!].
    764 
    765 						*[_CTRL-I*
    766 [ CTRL-I		Jump to the first line that contains the keyword
    767 		under the cursor.  The search starts at the beginning
    768 		of the file.  Lines that look like a comment are
    769 		ignored (see 'comments' option).  If a count is given,
    770 		the count'th matching line is jumped to, and comment
    771 		lines are not ignored.
    772 
    773 						*]_CTRL-I*
    774 ] CTRL-I		like "[ CTRL-I", but start at the current cursor
    775 		position.
    776 
    777 						*:ij* *:ijump*
    778 :[range]ij[ump][!] [count] [/]pattern[/]
    779 		Like "[ CTRL-I"  and "] CTRL-I", but search in
    780 		[range] lines (default: whole file).
    781 		See |:search-args| for [/] and [!].
    782 
    783 CTRL-W CTRL-I					*CTRL-W_CTRL-I* *CTRL-W_i*
    784 CTRL-W i		Open a new window, with the cursor on the first line
    785 		that contains the keyword under the cursor.  The
    786 		search starts at the beginning of the file.  Lines
    787 		that look like a comment line are ignored (see
    788 		'comments' option).  If a count is given, the count'th
    789 		matching line is jumped to, and comment lines are not
    790 		ignored.
    791 
    792 						*:isp* *:isplit*
    793 :[range]isp[lit][!] [count] [/]pattern[/]
    794 		Like "CTRL-W i"  and "CTRL-W i", but search in
    795 		[range] lines (default: whole file).
    796 		See |:search-args| for [/] and [!].
    797 
    798 						*[d*
    799 [d			Display the first macro definition that contains the
    800 		macro under the cursor.  The search starts from the
    801 		beginning of the file.  If a count is given, the
    802 		count'th matching line is displayed.
    803 
    804 						*[d-default*
    805 		Jumps to the previous diagnostic in the current buffer
    806 		by default. |vim.diagnostic.jump()| |default-mappings|
    807 
    808 						*]d*
    809 ]d			like "[d", but start at the current cursor position.
    810 
    811 						*]d-default*
    812 		Jumps to the next diagnostic in the current buffer by
    813 		default. |vim.diagnostic.jump()| |default-mappings|
    814 
    815 						*:ds* *:dsearch*
    816 :[range]ds[earch][!] [count] [/]string[/]
    817 		Like "[d"  and "]d", but search in [range] lines
    818 		(default: whole file).
    819 		See |:search-args| for [/] and [!].
    820 
    821 						*[D*
    822 [D			Display all macro definitions that contain the macro
    823 		under the cursor.  Filenames and line numbers are
    824 		displayed for the found lines.  The search starts
    825 		from the beginning of the file.
    826 
    827 						*[D-default*
    828 		Jumps to the first diagnostic in the current buffer by
    829 		default. |vim.diagnostic.jump()| |default-mappings|
    830 
    831 						*]D*
    832 ]D			like "[D", but start at the current cursor position.
    833 
    834 						*]D-default*
    835 		Jumps to the last diagnostic in the current buffer by
    836 		default. |vim.diagnostic.jump()| |default-mappings|
    837 
    838 						*:dli* *:dlist*
    839 :[range]dli[st][!] [/]string[/]
    840 		Like `[D`  and `]D`, but search in [range] lines
    841 		(default: whole file).
    842 		See |:search-args| for [/] and [!].
    843 		Note that `:dl` works like `:delete` with the "l"
    844 		flag, not `:dlist`.
    845 
    846 						*[_CTRL-D*
    847 [ CTRL-D		Jump to the first macro definition that contains the
    848 		keyword under the cursor.  The search starts from
    849 		the beginning of the file.  If a count is given, the
    850 		count'th matching line is jumped to.
    851 
    852 						*]_CTRL-D*
    853 ] CTRL-D		like "[ CTRL-D", but start at the current cursor
    854 		position.
    855 
    856 						*:dj* *:djump*
    857 :[range]dj[ump][!] [count] [/]string[/]
    858 		Like "[ CTRL-D"  and "] CTRL-D", but search  in
    859 		[range] lines (default: whole file).
    860 		See |:search-args| for [/] and [!].
    861 
    862 CTRL-W CTRL-D					*CTRL-W_CTRL-D* *CTRL-W_d*
    863 CTRL-W d		Open a new window, with the cursor on the first
    864 		macro definition line that contains the keyword
    865 		under the cursor.  The search starts from the
    866 		beginning of the file.  If a count is given, the
    867 		count'th matching line is jumped to.
    868 
    869 					*CTRL-W_d-default*
    870 		Mapped to |vim.diagnostic.open_float()| by default.
    871 		|default-mappings|
    872 
    873 						*:dsp* *:dsplit*
    874 :[range]dsp[lit][!] [count] [/]string[/]
    875 		Like "CTRL-W d", but search in [range] lines
    876 		(default: whole file).
    877 		See |:search-args| for [/] and [!].
    878 
    879 						*:checkp* *:checkpath*
    880 :checkp[ath]		List all the included files that could not be found.
    881 
    882 :checkp[ath]!		List all the included files.
    883 
    884 							*:search-args*
    885 Common arguments for the commands above:
    886 [!]	When included, find matches in lines that are recognized as comments.
    887 When excluded, a match is ignored when the line is recognized as a
    888 comment (according to 'comments'), or the match is in a C comment
    889 (after "//" or inside `/* */`).  Note that a match may be missed if a
    890 line is recognized as a comment, but the comment ends halfway the
    891 line.  And if the line is a comment, but it is not recognized
    892 (according to 'comments') a match may be found in it anyway.  Example: >
    893 	/* comment
    894 	   foobar */
    895 <	A match for "foobar" is found, because this line is not recognized as
    896 a comment (even though syntax highlighting does recognize it).
    897 Note: Since a macro definition mostly doesn't look like a comment, the
    898 [!] makes no difference for ":dlist", ":dsearch" and ":djump".
    899 [/]	A pattern can be surrounded by "/".  Without "/" only whole words are
    900 matched, using the pattern "\<pattern\>".  Only after the second "/" a
    901 next command can be appended with "|".  Example: >
    902 :isearch /string/ | echo "the last one"
    903 <	For a ":djump", ":dsplit", ":dlist" and ":dsearch" command the pattern
    904 is used as a literal string, not as a search pattern.
    905 
    906 ==============================================================================
    907 7. Using 'tagfunc'						*tag-function*
    908 
    909 It is possible to provide Vim with a function which will generate a list of
    910 tags used for commands like |:tag|, |:tselect|, Normal mode tag commands like
    911 |CTRL-]| and for the |taglist()| function.
    912 
    913 The function used for generating the taglist is specified by setting the
    914 'tagfunc' option.  The function will be called with three arguments:
    915   pattern	The tag identifier or pattern used during the tag search.
    916   flags	String containing flags to control the function behavior.
    917   info		Dict containing the following entries:
    918 	    buf_ffname	  Full filename which can be used for priority.
    919 	    user_data	  Custom data String, if stored in the tag
    920 			  stack previously by tagfunc.
    921 
    922 Note that "a:" needs to be prepended to the argument name when using it.
    923 
    924 Currently up to three flags may be passed to the tag function:
    925  'c'		The function was invoked by a normal command being processed
    926         (mnemonic: the tag function may use the context around the
    927 	cursor to perform a better job of generating the tag list.)
    928  'i'		In Insert mode, the user was completing a tag (with
    929 	|i_CTRL-X_CTRL-]| or 'complete' contains "`t`" or "`]`").
    930  'r'		The first argument to tagfunc should be interpreted as a
    931 	|pattern| (see |tag-regexp|), such as when using: >
    932 	  :tag /pat
    933 <		It is also given when completing in insert mode.
    934 	If this flag is not present, the argument is usually taken
    935 	literally as the full tag name.
    936 
    937 Note that when 'tagfunc' is set, the priority of the tags described in
    938 |tag-priority| does not apply.  Instead, the priority is exactly as the
    939 ordering of the elements in the list returned by the function.
    940 							*E987*
    941 The function should return a List of Dict entries.  Each Dict must at least
    942 include the following entries and each value must be a string:
    943 name		Name of the tag.
    944 filename	Name of the file where the tag is defined.  It is
    945 		either relative to the current directory or a full
    946 		path.
    947 cmd		Ex command used to locate the tag in the file.  This
    948 		can be either an Ex search pattern or a line number.
    949 Note that the format is similar to that of |taglist()|, which makes it possible
    950 to use its output to generate the result.
    951 The following fields are optional:
    952 kind		Type of the tag.
    953 user_data	String of custom data stored in the tag stack which
    954 		can be used to disambiguate tags between operations.
    955 
    956 If the function returns |v:null| instead of a List, a standard tag lookup will
    957 be performed instead.
    958 
    959 It is not allowed to change the tagstack from inside 'tagfunc'.  *E986*
    960 It is not allowed to close a window or change window from inside 'tagfunc'.
    961 *E1299*
    962 
    963 The following is a hypothetical example of a function used for 'tagfunc'.  It
    964 uses the output of |taglist()| to generate the result: a list of tags in the
    965 inverse order of file names.
    966 >vim
    967 function CompareFilenames(item1, item2)
    968   let f1 = a:item1['filename']
    969   let f2 = a:item2['filename']
    970   return f1 >=# f2 ? -1 : f1 <=# f2 ? 1 : 0
    971 endfunction
    972 
    973 function TagFunc(pattern, flags, info)
    974   let result = taglist(a:pattern)
    975   call sort(result, "CompareFilenames")
    976 
    977   return result
    978 endfunc
    979 set tagfunc=TagFunc
    980 <
    981 Note: When executing |taglist()| the 'tagfunc' function won't be called
    982 recursively.
    983 
    984 vim:tw=78:ts=8:noet:ft=help:norl: