vim 使用cscope数据库的最简单方法

王者归来 posted @ 2009年5月04日 19:06 in vim with tags cscope , 2989 阅读

cscope是Linux世界最流行的源代码交叉索引工具。vim和emacs也都提供有对应的配制文件。

在源代码的最上层目录执行cscope -Rbq,就可在当前目录生成针对c语言的数据库。

-R是递归搜索所有子目录

-b是不进入cscope的命令行

-q是生成加快索引速度的cscope.in.out和cscope.po.out

-k是针对浏览内核代码提供的,即不索引到/usr/include中。因为内核不使用这些头文件。

因为vim会在环境变量CSCOPE_DB不存在的情况下,加载当前目录的数据库。

尽量不要使用环境变量CSCOPE_DB,这是多年使用后的经验。因为当在多个工程间切换,就需要手动

修改变量值,尽管可以通过脚本实现快速切换,由此带来的复杂度,也是得不偿失。

 

所以我所说的最简单的办法就是在含有数据库的当前目录中启动vim,数据库就会被加载。

每个工程的数据库都保存在该工程的最上层目录,这也就避免了多个工程间切换的过程。

当然上面所有都是建立在配制好的vim和cscope环境的基础上的。

如何配制可参考官方提供的详细的中文说明

实际上只有一步,就是下载cscope_maps.vim,放到$HOME/.vim/plugin中,目录不存在就自己创建。

 

$ mkdir -p $HOME/.vim/plugin

 

然后就可以使用该配制文件里定义的快捷键进行索引了。

 

官方定义的快捷键有CTRL-空格,与中文用户常用输入法SCIM和ibus都冲突。

所以我修改了一下,使用CTRL-[,有兴趣的可以试试

deep cleaning dubai 说:
2019年9月14日 22:08

This kind of state regarding uncleanliness offers an oxygen of disorganization and also unprofessionalism to be able to clients and also customers. A washing service can ensure your organization always offers well to be able to visitors, along with provide an even more comfortable office for the employees.

monthly maid service 说:
2021年9月02日 16:29

They're are just some of the reasons that you need to hire washing companies, whether yourself or for your beloved. Let's confront it-you may possibly rather pay out fifteen hundred or so pounds as compared to see the grandmother or perhaps grandfather acquire hurt wanting to clean a thing that you or somebody else could clean in the same way easily.

maids in dubai 说:
2021年9月02日 16:32

Are you fine with accidental breakage of your household items? It is a fact that the maids from home cleaning services are well trained and they work with caution, but accidents DO happen. Hiring a licensed company will increase the probability of the maids being more educated and careful in whatever they do. Some companies even provide accidental breakage insurance coverage.

House Cleaning Servi 说:
2021年9月19日 19:29

Many cleaning services is there that may help you to accomplish the work. But just before that, because the workplace belongs for your requirements, you have to get a quick idea about how precisely you could create the area. In addition compared to that, you also can go by means of various procedures of washing. This will lessen your stress about the matter.

part time maids in d 说:
2023年8月10日 17:31

Towards win further estimates, establish on your client's minds that they can receive better value from most people. The route to sell more is almost always to educate your visitors. Selling might be education, and educating your visitors will allow you to receive more potential customers. Does the litigant believe that you will give them awfully when you should do work for your children.

house cleaning servi 说:
2023年10月18日 18:08

Home becomes mucky and unnatural but people ignore it all because people just wouldn't have the point in time! And it is actually in occasions like those that we need to make a good wish "It may have been which means that nice if we'd a maid or simply a cleaning service provider that could maintain our home for folks.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter