Talk vim together (18th: Vim plugin cscope cont.)

Source: Internet
Author: User
Tags function definition


Everyone crossing, welcome to listen to the large-scale couplet science fiction: Vim. Last time we introduced the cscope in the Vim plugin.

Last time, we were mainly talking about the plug-in's functionality and how to install the plugin. This time, let's keep talking about the plugin, but we say

is how to use the plugin. Well, still that sentence, gossip Hugh, words return to the positive turn. Let's talk about vim together!


Crossing, the steps to use Cscope are as follows:

    • 1. Generate the database file:

Cscope is a file list to generate the database files, so we are a file list for our husband. Crossing generate File List

It can be done by looking up a file, and sorting out the results is a list of files. When I say so, we all know what to use.

command to generate a list of files. "Find". Congratulations! That's correct. Here is the command to generate a list of files:

Find. -name "*.h"-o-name "*.c" > Cscope_files

This command indicates that files with the suffix. h and. C are looked up under the current directory, and the results are stored in the current directory Cscope_files

File. Once the command is completed, a list of files can be generated, and then we generate the database file through this list of files.

Here is the command to build the database:

Cscope-bkq-i Cscope_files.

After the command is executed, three database files are generated in the current directory: Cscope.out, Cscope.in.out, Cscope.po.out.


    • 2. Import the database file:

Open Vim, then press the colon to enter command mode, and execute the command: CS add/dir/cscope.out

This will import the cscope generated library file into vim. Note that the dir in the command just now indicates that the Cscope database file

In the directory, you need to enter the directory address according to the actual situation.


    • 3. Quickly locate content:

positioning content is mainly implemented by commands, different commands can locate different content, the following is the specific command:

Locate file: CS find F Name (name indicates the names of files that need to be located, the meaning of name in the following command is the same)

locating string: CS Find s name

positional variable or function definition: CS Find g name

Locate the function calling function named Name: CS Find C name


These commands need to be executed in VIM's command mode. After the command is executed, a window is generated below the current Vim window, and the window

Displays the result of the command execution, preceded by a line number, and can be used to know the number of results. Operation of the execution knot in the newly generated window

As with VIM (if you forget, you can review the VIM blade in the previous chapter). If you want to see a specific execution result,

The last line of the result of the command execution, which is the hint: Type number and <Enter> (empty cancels):

Where you enter the line number in front of the result. For example, if you want to see the details of the 5th command execution, then enter 5 and press ENTER to leave

Open the current window to jump to the 5th result is located in the file. Of course, the current window will be closed, after all he is a temporary

The window used to display the result of the command execution.


Crossing, let's try it out for ourselves at the end of the previous one. There are crossing and I said, use is not comfortable, even don't know

How to use the road. I think, through this explanation, we will be able to understand how to use cscope this plugin in vim. Crossing!

May be in the beginning to use the time feel not accustomed to, this is normal, I hope you practice more. When you are skilled, you can not leave him.

This is the same as vim, just beginning to feel very difficult to use, with proficiency after the love.


You crossing, about the Vim plugin: Cscope, today, so far. In the back of the chapter, we will also say that the other VIM plug

Thing Do you want to know what plugins are in the future? and listen to tell.

Talk vim together (18th: Vim plugin cscope cont.)

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.