Ctags + vim, the source code reading tool in Linux

Source: Internet
Author: User
Article Title: ctags + vim, the source code reading tool in Linux. Linux is a technology channel of the IT lab in China. Including desktop applications, Linux system management, kernel research, embedded systems, open source, and other basic categories 1. Install ctags
 
Download the source code to the http://ctags.sourceforge.net, unzip
 
$./Configure
 
$ Make
 
$ Sudo make install
 
2. Run the command in the source code directory.
 
$ Ctags-R
 
"-R" indicates recursive creation, that is, the source code under all subdirectories under the source code root directory. The tags index file is generated under the current directory.
 
Assume that the current source code directory contains the following content:
 
. /Makefile
 
. /Src # source code folder
 
After ctags-R is executed
 
. /Makefile
 
. /Src # source code folder
 
. /Tags
 
The "tags" file contains a list of these objects:
 
Macro defined by # define
 
Enumerated variable value
 
Function Definition, prototype, and Declaration
 
Namespace)
 
Type Definition (typedefs)
 
Variables (including definitions and declarations)
 
Class, struct, enum, and union)
 
Class, structure, and union member variables or functions
 
3. vim will use the index in the tags file to locate
 
Run vim in the directory where the tags file is located to open the source file. C or. H
 
A. move the cursor to the position of the variable or function to be viewed. Press ctrl +] to jump to the position defined by the variable or function, and press ctrl + o to return.
 
B. Stop the cursor at the place referenced by the header file. Press the gf key to jump to the header file. ctrl + o returns
 
C. Place the cursor in the position of a function or variable. gd will highlight all functions or variables in the current file and press n to view the next one.
 
D. gg The cursor returns to the top of the file
 

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.