vim下ctags使用

1. cd to the root directory of your code:
2.Run Ctags recursively over the entire code to generate the tags file
ctags -R *
3. To search for a specific tag and open Vim to its definition, run the following command in your shell:
vim -t
4. Or, open any Linux source file in Vim and use the following basic commands:
Ctrl-] Jump to the tag underneath the cursor
:ts Search for a particular tag
:tn Go to the next definition for the last tag
:tp Go to the previous definition for the last tag
:ts List all of the definitions of the last tag
Ctrl-t Jump back up in the tag stack
The first command is probably the one you will use most often: it jumps to the definition of the tag (function name, structure name, variable name, or pretty much anything) under the cursor. The second command can be used to search for any tag, regardless of the file that is currently opened. If there are multiple definitions/uses for a particular tag, the tn and tp commands can be used to scroll through them, and the ts command can be used to “search” a list for the definition you want (useful when there are dozens or hundreds of definitions for some commonly-used struct). Finally, the last command is used to jump back up in the tag stack to the location you initiated the previous tag search from.

Jerky Lu wechat
欢迎加入微信公众号