[Essential tool for software developers in LINUX] ctags

Source: Internet
Author: User
[Essential tool for software developers in LINUX] we are familiar with ctags. in some cases, ctags are the only available text editor in Linux. In fact, the VI we usually refer to is actually VIM (ViImproved, VI enhanced version ). Some people often compare VIM with emacs, although VIM is not like... [essential tool for software developers in LINUX] we are familiar with ctags. in some cases, ctags are the only available text editor in Linux. In fact, the VI we usually refer to is actually VIM (ViImproved, VI enhanced version ). Some people often compare VIM with emacs. although VIM does not have as many features as emacs, it is more convenient and easy to use than emacs. VIM is easy to use. you only need to look at the built-in vitutor of VIM, and you only need to know how to use VIM in about 20 minutes. For C/C ++ programmers in Linux, using the combination of VIM + Ctags to write programs may be the best choice. The usage of ^_^ VI will not be repeated here. this article assumes that you have spent 20 minutes learning vitutor. ^_^ This section describes the Ctags program. Although ctags supports other editors, it only officially supports VIM. Ctags has been installed by default in VIM, which helps programmers easily browse the source code. To use ctags skillfully, you only need to remember the following seven commands: (very simple, haha) 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 we will explain the above Command one by one: "$ ctags-R *": "-R" indicates recursive creation, which also includes the source code root directory (current directory) all subdirectories under. "*" 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. Pai_^ note: when running vim, it must be run 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 coding, you can manually delete the tags file (the hacker cannot get it, and the dust won't run away by yourself ^_^ ).
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.