Using Vim + Ctags

Source: Internet
Author: User

Usually in Linux or other *nix environments we use VIM as the Code editing tool, which is almost irreplaceable under the pure command terminal. It has a very powerful extension mechanism and is basically omnipotent in terms of text editing. However, Emacs users please do not be excited, the author has not really used Emacs, although I know it can even make coffee, or so I have time to try to cook a cup of coffee while drinking and writing.

Readers who write code under Linux are recommended to try ctags more or less. Ctags supports a very wide range of languages, which can be extracted from various symbols in the source code (such as functions, macro classes, etc.) and tagged and saved to a file for retrieval by other text editing tools (Vim,emacs, etc.). It preserves the file format that conforms to the UNIX philosophy (small i.e. beauty) and is more concise to use:

/server-R #小技巧: in the current directory generated by the tags file is a relative path,#若改用 ctags-r/server/, you can generate a ctags containing the full path, you can freely put into any folder. added in #在 ~/.VIMRC:set tags+=/server/php-src/tags#或者在vim中运行命令::set tags+=/server /php-src/tags            

The above code will generate a file called tags in the/sever/php-src directory, the format of this file is as follows:

{tagname}<tab>{tagfile}<tab>{tagaddress} eg  zend/zend_globals_macros.h  /^# define EG (/; "   D

Each of its lines is one of the above formats, the first column is the symbol name (eg macro above), the second column is the file location of the symbol and the location of the symbol. Vim can read the tags file, and when we use Ctrl +] on the symbol (which can be a variable name), VIM will attempt to retrieve the symbol from the tags file. If found, opens the file based on the file that contains the symbol and the location of the symbol, and positions the cursor where the symbol definition is located. So that we can quickly find the definition of the symbol.

Use Ctrl +] to automatically jump to the definition,ctrl+t can return to the last view location. This allows you to "swim" between the code quickly.

When you get used to this way of browsing the code, you'll feel very handy. However, if you are not accustomed to using Vim as an editor, you can also look at the IDE described below.

Using Vim + Ctags

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.