C++如何在vim使用cscope
【下载地址】
http://cscope.sourceforge.net/
【文章】
如何在c++中使用scope:
http://www.yuanma.org/data/2006/0908/article_1487.htm
【介绍】
中文帮助手册, 用下面的命令看看介绍吧:
:help if_cscop.txt
【使用方法】
一、c中使用方法:
1、shell> cd /home/wooin/vim71/
2、>cscope -Rbkq
3、 此后会生成三个文件
$ ll cscope.*
-rw-rw-r-- 1 wooin wooin 1.1M 2007-09-30 10:56 cscope.in.out
-rw-rw-r-- 1 wooin wooin 6.7M 2007-09-30 10:56 cscope.out
-rw-rw-r-- 1 wooin wooin 5.1M 2007-09-30 10:56 cscope.po.out
4、 打开文件, 开始Coding
shell> cd src
shell> main.c
5、进入vim后第一件事是要把刚才生成的cscope文件导入到vim中来, 用下面的命令:
:cs add /home/wooin/vim71/cscope.out /home/wooin/vim71
上面这条命令很重要, 必须写全, 不能只写前半句:
:cs add /home/wooin/vim71/cscope.out
6. 或者直接在 cscope.out的目录下使用
> cscope -d
二、cscope find的用法:
cs find c|d|e|f|g|i|s|t name
0 或 s 查找本 C 符号(可以跳过注释)
1 或 g 查找本定义
2 或 d 查找本函数调用的函数
3 或 c 查找调用本函数的函数
4 或 t 查找本字符串
6 或 e 查找本 egrep 模式
7 或 f 查找本文件
8 或 i 查找包含本文件的文件
三、cscope find得快捷方式:
添加到~/.vimrc中, 并重启vim:
nmap <C-c><C-k> :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-c><C-g> :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-c><C-l> :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-c><C-t> :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-c><C-e> :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-c><C-f> :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-c><C-i> :cs find i ^<C-R>=expand("<cfile>")<CR><CR>
nmap <C-c><C-d> :cs find d <C-R>=expand("<cword>")<CR><CR>
四、 c++中使用cscope
-R: 在生成索引文件时,搜索子目录树中的代码
-b: 只生成索引文件,不进入cscope的界面
-k: 在生成索引文件时,不搜索/usr/include目录
-q: 生成cscope.in.out和cscope.po.out文件,加快cscope的索引速度
#!/bin/sh
find . -name "*.h" -o -name "*.c" -o -name "*.cc" -o -name "*.cpp" > cscope.files
cscope -bkq -i cscope.files
ctags -R
--cscope在kernel中使用
http://cscope.sourceforge.net/large_projects.html