cscope使用简介
来源:互联网 发布:网络的危害英语作文 编辑:程序博客网 时间:2024/06/05 15:18
cscope最早是由一位Joe Steffen的开发者,为了方便自己的工作而开发的。后来,在PDP-11上开发一项大工程时,进行改进。最后是在2000年由SCO公司开源。http://cscope.sourceforge.net/cscope主要是和vim搭配使用,主要的作用是查找函数、宏、变量或者字符串的引用。类似ctags但是更强大。安装很简单,Ubuntu可以使用apt-get install安装,centos可以使用yum install安装,也可以下载安装包,敲./configure make make install安装。使用也比较方便,首先,为你的代码生成数据库cscope -Rbqk-R:为当前目录下所有子目录创建数据库-b:生成数据库之后不启动自带的查询界面-q:生成cscope.in.out和cscope.po.out,加快搜索速度-k:跳过/usr/include目录执行完毕之后,当前目录会多出三个文件cscope.out //生成的符号索引cscope.in.outcscope.po.outcscope支持8种查询:s:查找C语言符号,即函数名,宏,变量等g:查找函数,宏,变量等定义的位置,相当于转到定义d:查找本函数调用的函数c:查找调用本函数的函数t:查找指定的字符串e:查找egrep功能f:查找并打开文件i:查找包含本文件的文件在vim中使用cscope有两种方法:1、不用配置vimrc文件,直接使用命令:cs f(ind) g fun2、写入vimrc文件,可以定义快捷键,例如:Ctrl + \ + gvimrc配置可如下参考
if has(“cscope”)
set csprg=/usr/bin/cscopeset cstset cscopetagset csto=0set nocsverbif filereadable("cscope.out") cs add cscope.outelseif $CSCOPE_DB != "" cs add $CSCOPE_DBendifset csverbset cscopeverbosenmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>nmap <C-\>i :cs find i <C-R>=expand("<cfile>")<CR><CR>nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR>nmap <C-@>g :scs find g <C-R>=expand("<cword>")<CR><CR>nmap <C-@>c :scs find c <C-R>=expand("<cword>")<CR><CR>nmap <C-@>t :scs find t <C-R>=expand("<cword>")<CR><CR>nmap <C-@>e :scs find e <C-R>=expand("<cword>")<CR><CR>nmap <C-@>f :scs find f <C-R>=expand("<cfile>")<CR><CR>nmap <C-@>i :scs find i <C-R>=expand("<cfile>")<CR><CR>nmap <C-@>d :scs find d <C-R>=expand("<cword>")<CR><CR>nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>nmap <C-@><C-@>i :vert scs find i <C-R>=expand("<cfile>")<CR><CR>nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
endif
注:查找包含本文件的快捷键中,大部分网上版本使用nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>但是我的计算机提示“找不到匹配的结果”,修改为上述方式可行综上,基本的cscope使用已经介绍完了,在使用过程中,需要特别注意的是,ctrl+\是同时按下,然后紧接着按g或者其他键,不能三个键同时按下。
阅读全文
0 0
- cscope使用简介
- cscope 使用
- cscope使用
- cscope使用
- cscope使用
- cscope 使用
- cscope使用
- 使用cscope
- cscope 使用
- cscope使用
- cscope使用
- cscope 使用
- 使用cscope
- cscope使用
- 使用cscope
- cscope使用
- cscope使用
- 使用Vim + Cscope/Ctags|Vim,Cscope,Ctags
- 央视:乐视网是创业失败还是涉嫌欺诈?
- 使用JestClient操作ElasticSearch
- Linux-NFS——配置过程
- 《剑指offer》连续子数组的最大和
- flex 基础
- cscope使用简介
- Ubuntu下Android Studio的设备连接后设备名后为[null]的解决方法
- 局部极大值
- 双日历插件My97DatePicker
- Git学习笔记
- 解决Android设置Style中Activity的退出动画无效问题
- js 和 oc 调用
- java文本之撤销与恢复
- 【二叉树】二分查找树,中序遍历,统计出现次数最多的节点【Add to List 501. Find Mode in Binary Search Tree】