"Go" read edit code with Vim+taglist+ctags

Source: Internet
Author: User

"description": The following article is excerpted from the network, if there is infringement please contact me.

Linux System under the source reading tool Ctags vim

1. Install Ctags

To http://ctags.sourceforge.net download source code, after decompression

$./configure

$ make

$ sudo make install

2. Execute under the source directory

$ ctags-r

"-R" means recursive creation, and includes all subdirectories under the source code root, and tags index files are generated under the current directory.

Assume that the current source directory contains the following content

./makefile

./SRC #源码存放的文件夹

After performing Ctags-r

./makefile

./SRC #源码存放的文件夹

./tags

A list of these objects is included in the "tags" file:

Macros defined with #define

The value of an enumerated type variable

Definitions, prototypes, and declarations of functions

Name Space (namespace)

Type definition (typedefs)

Variables (including definitions and declarations)

Classes (Class), struct (struct), enum type (enum) and Union (union)

member variables or functions in classes, structs, and unions

3.vim will be positioned by index in tags file.

Run vim in the directory where the tags file resides open the source file. C or. h

A. Move the cursor to the position of the variable or function you want to view, CTRL can jump to the position defined by the variable or function, Ctrl o return.

B. The cursor stops where the header file refers, press the GF key to jump to the header file, Ctrl o return

C. Place the cursor in the position of the function or variable, GD will highlight all the functions or variables in the current file, and press N to view the next

D. GG Cursor returned to the top of the file

Linux reads edit code with Vim+taglist+ctags

In fact, this set of combination is very practical, basically to the mouse source Insight realm, the most important thing is that you can run in text mode.

The platform used is Fedora 8,vim and ctags after the F8 installation has been completed.

TagList need to download it yourself

1, download a taglist zip file, and then extract the Taglist.vim copy to the ~/.vim/plugin directory.

2. Modify ~/.vim/plugin/taglist.vim

Add to the If!exists (' loaded_taglist ') above

Let tlist_ctags_cmd= "/usr/bin/ctags"

The results are:

"Line continuation used here
Let S:cpo_save = &CPO
Set Cpo&vim
Let tlist_ctags_cmd= "/usr/bin/ctags"
If!exists (' Loaded_taglist ')
"The Loading the TagList plugin
"
"To speed up the loading of Vim, the TagList plugin uses autoload
"Mechanism to load the TagList functions.
"Only define the configuration variables, user commands and some
"Auto-commands and finish sourcing the file
"The TagList plugin requires the built-in Vim system () function. If this
"function is not available, then don t load the plugin."
If!exists (' *system ')
Echomsg ' Taglist:vim system () built-in function is not available. ' .
' Plugin is not loaded. '
Let loaded_taglist = ' no '
Let &CPO = S:cpo_save
Finish
endif

At this point ctags and taglist have been combined.

3, in the corresponding source directory run ctags-r produce the corresponding tags file

4, will tags file in the VIM runtime import. You can modify ~/.VIMRC, and each time you start Vim will automatically import this tags file

: Set Tags=/root/develop/honeyids/tags

and set syntax highlighting

Syntax enable

Syntax on

5, running VIM, activating taglist: Taglisttoggle command. Use ctrl+2 w when switching between the tags area on the left and the normal editing area.

6. When using Ctags, CTRL +] can view the definition of the function. Ctrl+o returns the source file.

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.