Using the Ctags tool in Vim

Source: Internet
Author: User

1 Ctags Introduction Ctags generates a markup file to help locate an object in the source file.


2 its generated tag file tags include a list of these objects:

Macros defined with # define
The value of the enumeration type variable
Definitions, prototypes, and declarations of functions
Namespaces (namespace)
Type definition (typedefs)
Variables (including definitions and declarations)
class, struct (struct), enum type (enum), and Union (union)
member variables or functions in classes, structs, and unions


3 Installation # Yum-y install Ctags


4 Production Tags file

4.1 Jump to project directory $ cd/home/test/mywork


4.2 Generating tags files $ ctags-r--fields=+ls/home/test/mywork


–fields=[+|-]flags
Define a valid extension field in the Label file table entry (see tag, document FORMAT below for more information). Flags parameter
is a set of single letter marks, each representing an extension field of one type, with the following meanings (disabled by default unless
indicated):


Access control information for Class A members
F-scope partial to file [enable]
I (about) the information of the inheritance
K the label type represented by a character [enable]
Full name of K tag type
L programming language type that contains the source file for this label
Information about the implementation of M (about)
n the line number where the label appears
S-label range [Enable]
The fingerprint of the S function (for example, a prototype or a parameter list)
Z include "kind:" keyword in the kind field
t the type and name of the variable or typedef as "TypeRef:" field [Enable] (*)


4.3 Read the tags file $ cat/home/test/mywork/tags
mytest/home/test/mywork/index.php/^class mytest$/; " C language:php
display/home/test/mywork/index.php/^ Public Function display () $/; " F language:php
start/home/test/mywork/db/conn/mysql.php/^function start () $/; " F language:php
start/home/test/mywork/index.php/^ Public Function start () $/; " F language:php
t/home/test/mywork/start.php/^ $t = new Mytest (); $/; " V language:php


5 Using the tags file

5.1 Read tags file tags must be in the current directory of Vim run in order to correctly jump in vim.
If this tags is used frequently. Can be added to the ~/.VIMRC
$ vim ~/.VIMRC
Set Tags+=/home/test/mywork/tags


After Vim opens the project. You can view all tags that are loaded in the following ways

: Echo &tags

./tags,./tags,tags,tags,/home/test/mywork/tags

5.2 Commands using CTRL +]: Jump to current tab
CTRL + O: Move back to the previous tab
: Tags lists all the jump tag tags
: 3tag Callback 3 steps
: Tag tagname back to the specified tag


6 Chinese Reference File Ctag configuration of various detailed documents: http://easwy.com/blog/archives/exuberant-ctags-chinese-manual/.

Using the Ctags tool in Vim

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.