Vim + Cscope打造Linux下的Source Insight
来源:互联网 发布:录制绘画过程软件 编辑:程序博客网 时间:2024/06/05 10:49
Source Insight是Windows下最方便浏览代码的工具。但是Source Insight是没有Linux版本的。为了方便在Linux下浏览代码并进行学习,可以利用Vim配合Cscope来打造Linux下的Source Insight。
Cscope是Vim适用的工具和插件,通过Cscope可以方便地获知某个函数的定义以及被哪些函数调用。
Cscope安装
可以在http://cscope.sourceforge.net/下载源码包,然后解压,编译安装。
./configure
make
make install
生成Cscope数据库
使用cscope前,必须为代码生成一个cscope数据库。假设当前代码在/usr/src/linux目录下,则运行下列命令。
cd /usr/src/linux
cscope –Rbq
然后会生成3个文件:cscope.in.out,cscope.out,cscope.po.out。
用vim打开代码文件,将刚才生成的cscope文件导入到vim中。
vim init/main.c
:cs add /usr/src/linux/cscope.out /usr/src/linux
也可以将下面语句添加到vim的配置文件.vimrc中。
if fileradable("cscope.out") cs add csope.outelseif $CSCOPE_DB != "" cs add $CSCOPE_DBendif
Cscope的功能
Cscope的功能通过它的子命令“find”来实现。
cs find c|d|e|g|f|i|s|t name
- s:查找C代码符号
- g:查找本定义
- d:查找本函数调用的函数
- c:查找调用本函数的函数
- t:查找本字符串
- e:查找本egrep模式
- f:查找本文件
- i:查找包含本文件的文件
可以在.vimrc中添加下面的快捷键,免得每次都要输入一长串命令。
nmap <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("<cword>")<CR><CR>nmap <C-@>i :cs find i ^<C-R>=expand("<cword>")<CR>$<CR>nmap <C-@>d :cs find d <C-R>=expand("<cword>")<CR><CR>
使用时,将光标停留在要查找的对象上,按下<C-@>g,即先按“Ctrl+@”,然后很快再按“g”,将会查找该对象的定义。
0 0
- Vim + Cscope打造Linux下的Source Insight
- Vim + Cscope打造Linux下的Source Insight
- Vim+Ctags+Cscope打造linux下的source insight
- Vim + Cscope打造Linux下的Source Insight
- Vim + Cscope打造Linux下的Source Insight
- Vim + Cscope打造Linux下的Source Insight
- Linux下用Vim+cscope+ctags打造具有Source Insight便利性的IDE
- 打造linux下的source insight——vim插件安装使用总结
- cscope,vim实现source insight
- 打造linux下的source insight--YouCompleteMe安装
- 如何将vim打造成Linux下的source insight
- 如何将vim打造成Linux下的source insight
- Linux下的Source Insight
- Linux下的Source Insight .
- ctags + cscope + vim + 打造 mac 环境下的VIM神器
- vim的source insight
- linux下source insight
- Linux下的Source Insight -- KScope
- 解决Android SDK下载和更新失败的方法详解
- Ubuntu的挂起和休眠
- Spring简介~~~我是Spring的搬运工
- 设计模式:二
- jQuery判断checkbox是否选中的3种方法
- Vim + Cscope打造Linux下的Source Insight
- ListView中为解决CheckBox重用而引入的新问题
- linux ubuntu 虚拟机中配置samba的实现文件共享的方法
- Linux/Centos:如何安装GCC(C和C++编译器)
- Android中的Menu介绍
- Ubuntu14.04 安装git
- Struts2的实际操作!简直不能太爽了
- 【Unity快速实现小功能】加载文本文件之——加载txt文件
- 网站会员整合ucenter 实现多站点同步登录方法