How to use the ctags code tracing tool

Source: Internet
Author: User
The ctags code tracing tool is easy to use. to use ctags, you only need to remember the following seven commands: 1. $ ctags & amp; ndash; R * ($ is a Linux Shell prompt) 2. $ vi & amp; ndash; ttag (replace the tag with the variable or function you want to search... the ctags code tracing tool is easy to use. to use ctags, you only need to remember the following seven commands: 1. $ ctags-R * ($ is a Linux Shell prompt) 2. $ vi-t tag (replace the tag with the variable or function name you want to search for) 3.: ts (the command starting with ":" In tags list is the command line mode command in VI) 4.: tp (tp help Note: tags preview) --- skip this command is not commonly used, you do not need to remember 5.: tn (tn mnemonic: tags next) --- skip this command is not commonly used, you do not need to remember 6. ctrl +] 7. ctrl + T next, let's explain it one by one. Command: "$ ctags-R *": "-R" indicates recursive creation, which includes all subdirectories under the source code root directory (current directory. "*" Indicates all files. This command will generate a "tags" file in the current directory. when you run vi in the current directory, it will automatically load this tags file. The Tags file contains a list of these objects: Defines, prototype, and declares the namespace type definition (typedefs) with the # define macro enumeration type variable value function) variables (including definitions and declarations) class, structure (struct), enumeration type (enum), and union) VIM uses the "tags" file to locate the marked objects in the class, structure, and union member variables or functions. The remaining command is the method to locate these objects: "$ vi-t tag": add the "-t" parameter when running vim, for example: the [/usr/src] $ vim-t main command will open the file defining "main" (variables, functions, or other) and position the cursor to this line. If this variable or function has multiple definitions, the ": ts" command in the VI command line mode can list a list for users to choose from. ": Tp" is the last tag file, and ": tn" is the next tag file. Of course, if the current tags file contains only one variable or function name, the ": tp,: tn" command is unavailable. (The most convenient way is to move the cursor over the variable or function name, and then press "Ctrl +]" to directly jump to the variable or function-defined source file, position the cursor to this line. You can use "Ctrl + t" to return the original location. Even if you use "Ctrl +]" for N times to find N variables, you can press "Ctrl + t" for N times to return to the originally opened file, which will be returned in the original way. Note: when running vim, you must run it in the directory where the "tags" file is located. Otherwise, run the ": settags =" command to set the path of the "tags" file so that vim can find the "tags" file. When encoding is completed, you can manually delete the tags file.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.