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