Use ctags in Linux to find the source code

Source: Internet
Author: User

Use ctags in Linux to find the source code

1. ctags introduction:

"Oh, how can I view the implementation of XX functions for this many files !" I believe this is a complaint from many friends. Too many files make it impossible for us to locate a function implementation or macro-defined position. Obviously, it is very unfavorable for reading source code and personal learning. I hope that a software can input commands to precisely locate the function position. Yes, now there is such a tool: ctags, which needs to be used with the vim editor to make it easier to read the source code.

Read the source code in Linux-ctags + vim

What is ctags?

Ctags (Generate tag files for source code) is a tool that facilitates code reading in vim. 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.

Ctags update address: Invalid.

What can ctags locate?

1) Use a macro defined by # define

2) enumerated variable value

3) Function Definition, prototype, and Declaration

4) namespace)

5) type definition (typedefs)

6) variables (including definitions and declarations)

7) class, struct, enum, and union)

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

2. Configure your environment to meet the requirements of ctags:

Run the yum command to install ctags:

Generate the tags file at the specified source code location, and add many parameters to improve the ctags function (to reflect its powerful functionality, I use it to generate the tags file of the linux source code ):

Then we can view the tags content and find that the original tags is the index of each element in the Linux kernel code, this is the reason why ctags can be quickly located in combination with vim (the query is based on the content of this file ):

 

  • 1
  • 2
  • Next Page

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.