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