How to use Ctags tool to quickly find source code in Linux

  

Ctags tool is mainly used to traverse source files, quickly find the symbols in the location source code, then how to use Ctags to find the source code under Linux? Let's take a look at the way to find source code using Ctags under Linux.

Too many files prevent us from locating the implementation of a function or the location of a macro definition. Obviously, the reading of the source code and the personal study are very unfavorable. How you want a software to be able to accurately position the function by entering commands. Yes, there is now a tool like ctags, which needs to be used with the vim editor to make source code reading easier.

What is ctags?

Ctags(Generate tag files for source code) is a tool for reading code under vim. Although ctags can support other editors, it only officially supports VIM. And Ctags has been installed by default in VIM, which helps programmers to easily browse the source code.

ctags update address: http://ctags.sourceforge.net/, this website is the official website of ctags, you can download the latest content about ctags above.

What can ctags target?

1) Macros defined with #define

2) Values ​​of enumerated variables

3) Definition, prototype and declaration of functions

4 ) namespace (namespace)

5) type definition (typedefs)

6) variables (including definitions and declarations)

7) class (class), structure (struct ), enum type (enum) and union (union)

8) class, structure, and union member variables or functions

2. Configure your own environment to satisfy ctags:

ctags installed, if it is RedHat, the direct use yum command to install:

tags generated source files in the specified location, and we add a lot of parameters to improve ctags function (in order to reflect its function powerful, I use it to generate tags linux source file):


then we see the tags content can be found, the original tags index is linux kernel code for each element, which is Ctags combined with vim can quickly locate the reason (query is through this ) To locate the pieces of content:

The above is a Linux system using Ctags find the source of the method described, Ctags use tools to quickly find the source you want, is not very easy to do? Give it a try.

Copyright © Windows knowledge All Rights Reserved