How to use ctags to track variables or functions in the vim editor

Source: Internet
Author: User
How to use ctags to implement variable or function tracing in the vim editor I believe that when you read a long and long code, you will often encounter the following situation: when you see a variable or function declaration or call, I don't know what this variable and function will do, so it will be very troublesome... information on how to use ctags to implement variable or function tracking in the vim editor I believe that you will often encounter the following situations when reading long code: when you see a declaration or call of a variable or function, you do not know what the function and the variable are, in this case, it is very troublesome to search for the sources of variables or functions in a line in the entire code. it is very troublesome and sometimes cannot be found for a long time. At this time, we can use ctags to help us complete this tedious task. (Ctas is installed by default in the system. you can run the command ctags on the terminal to check whether it is installed. if it is not installed, you can install it on your own.) now let's start with how to use ctags: step 1: Find the folder where the file you want to view is located. Generally, you are used to placing all the code to be viewed in the same folder. suppose the folder name is finddir, first use the cd command to go to the finddir folder, and then run the command: ctags-R. after executing this command, you will find that a tags file is added to the finddir folder. Step 2 is completed: modify the configuration file and execute the command vim/etc/vimrc in the middle of the file. add a set tags =/finddir/tags or execute vim ~ at the beginning of many set statements ~ /. Vimrc, and then add a line set tags =/finddir/tags to the file or execute vim ~ /. Vimrc, and then add a set tags =/finddir/tags line to save the file. Step 2: Use the vim-t filename command to open the file in the finddir directory, this is to find a variable or function. press ctrl +] to track down. press ctrl + t to track backward.
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.