How vim jumps to the function definition and finds where it was called-cscope use

Source: Internet
Author: User
Tags function definition

/********************************************************************* * Author:samson * date:07/02/2015 * Test PL Atform: * GCC (Ubuntu 4.8.2-19ubuntu1) 4.8.2 * GNU bash, 4.3.11 (1)-release (X86_64-PC-LINUX-GNU)  * Nginx Version: *              Nginx 1.6.2 *              nginx 1.8.0 * *******************************************************************/

in the world of vim, when viewing the source code, use the Ctags tool to implement a function method jump, to find in the source where the corresponding method is called or where it is defined, Only the grep command can be used to find it, which requires a different terminal or in the same terminal:!grep fucname./*-rn | grep tags, such a switch for SSH to remote operation is not so convenient, there is no better plug-in tool can directly complete the above functional requirements? Then use the Cscope tool, which can complete the functions described above, CTAGS+GREP can be installed in GNU Linux with the following command.

sudo apt-get install Cscope

How to use:
1. Download the Cscope_maps.vim (: Http://cscope.sourceforge.net/cscope_maps.vim) file and include it in your vim boot configuration file. If you are using the Vim 6.x version, you can arrange this file in the $HOME/.vim/plugin directory (if it is a different directory, please understand your ' runtimepath ' environment variable). If you are using a version of vim5.x, you can add all of the contents of this file to your $HOME/.VIMRC file, or add the "source Cscope_maps.vim" command in. VIMRC (Note that this file is in a recognizable path).

2, in the source code directory, executes the CSCOPE-RB method to generate the Cscope.out file, which is an index file, similar to the ctags generated tags index file the same role;

3. Open Vim, if you use a tag (symbol) already in C code (for example: ' vim-t main '), then vim jumps to where you want it. Move the cursor to a function in each source code in the program, type "CTRL-\ S" (that is, press CRTL-backslash, then press ' s '), and then you will see a pop-up window at the bottom of Vim, which shows the corresponding tag in the program. Select the appropriate one and type enter, and you will jump to the corresponding location. Like Ctags, you can type "ctrl-t" to go back to where you were before the search.

More ways to use:
Http://graceco.de/manual/cscope_vim_tutorial_zh.html

REF:
http://cscope.sourceforge.net/


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

How vim jumps to the function definition and finds where it was called-cscope use

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.