`
kenby
  • 浏览: 716404 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

vim + taglist + ctags + cscope 简单使用

阅读更多

ctags用来跳转, taglist用来列出当前文件的变量, 函数, 宏. cscope用来查找符号



一 使用ctags


1 在源码目录创建tag文件

cd /home/kenby/project/nginx-1.0.0/src

ctags -R


2 打开一个文件

gvim core/ngx_string.c

把光标移到变量名或函数名上,然后按下"Ctrl-]"。用"Ctrl-o"退回原来的地方。


二 使用taglist


打开一个文件, 并输入命令, vim就会产生一栏显示该文件的变量和函数

gvim core/ngx_string.c

:Tlist



三 使用cscope


1 生成 cscope.files

cd /

find /home/kenby/project/nginx-1.0.0/src -name '*.c' -o -name "*.h" > /home/kenby/project/nginx-1.0.0/src/cscope.files


2 生成 cscope.out

cd /home/kenby/project/nginx-1.0.0/src

cscope -b -q -k

这样在源码目录下产生一些 .out 索引文件


3 打开一个文件

gvim core/ngx_string.c


4 添加索引

:cs add cscope.out


5 输入下列命令, 试用cscope强大的查找功能

:cs f c ngx_log_error      查找此函数被哪些函数调用过

:cs f d ngx_log_error      查找此函数调用了哪些函数

:cs f g ngx_log_error      查找变量名或函数名的定义处

:cs f s  ngx_log_error     查找该符号出现的地方

:cs f t  variable              查找给该变量赋值的地方



四 vimrc配置文件

使用cscope, 每次都输入那么长的命令, 实在很伤手, 在vimrc配置一些快捷键:


if has("cscope")

  set csprg=/usr/bin/cscope

  set csto=1

  set cst

  set nocsverb

  " add any database in current directory

  if filereadable("cscope.out")

      cs add cscope.out

  endif

  set csverb

endif


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("<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>

 

分享到:
评论

相关推荐

    vim + ctags + cscope + nerdtree + taglist + vundle

    vim配置文件,包含taglist cscope nerdtree 等配置

    ctags,cscope,taglist.vim,cscope_maps.vim

    window下使用vim查看源码的好用插件,RAR里面有ctags,cscope,taglist.vim,cscope_maps.vim

    vim+ctags+cscope 配置文件

    自己的vim配置文件, 内含: 1. _vimrc 2. plugin: TagList, SuperTab, OmniCppComplete, Code_Complete 3. tags for glibc, C++(stl,stream), Unix98 system, glib-2.0 4. ftplugin for Pro*C/C++

    用vim+ctags+taglist+cscope打造文本模式下的Kscope

    简单介绍了一下Kscope的用法,希望对大家有所帮助

    vim plug taglist cscope

    vim plug taglist cscope,vim plug ubuntu

    vim+ctags+cscope配置文件V2.0.6

    自己的vim配置文件 1. .vimrc 2. plugins: TagList, SuperTab, OmniCppComplete, Code_Complete DoxygenToolkit, proc 3. c89, GNU libc, C++(stl,stream), IEEE Std 1003.1-2008, glib-2.0 的tags文件 4. ftplugin ...

    vim+ctags+cscope配置文件V1.0.0

    自己的vim配置文件 1. .vimrc 2. plugins: TagList, SuperTab, OmniCppComplete, Code_Complete DoxygenToolkit, proc 3. glibc, C++(stl,stream), Unix98 system, glib-2.0 的tags文件 4. ftplugin for Pro*C/C++ 5...

    windows cscop+ctags vim各种插件

    windows 环境的ctags和cscope还有DoxygenToolkit.vim minibufexpl.vim Tabular.vim taglist.vim visualmark.vim 插件工具

    vim使用手册

    在用VIM + cscope + ctags + taglist 读C代码时的常用操作

    打造linux下的Source Insight

    Source Insight是windows下非常好用的工程代码浏览工具,有很强的跟踪...为解决这一现实问题,本文利用vim+ctags+taglist+Cscope程序组合成功打造出不逊色于Source Insight的linux下工程代码浏览工具,现分享于此...

    vim配置文件及插件

    安装完vim+ctags+cscope以后将这个压缩包解压到家目录下,即可,带有常用插件taglist等,以及vimrc中一些很实用的配置

    vim configure

    VIM configure files, containing ctags, cscope configuration, and taglist and NERDtree plugins.

    VIM打包-V1.0

    Include: NERDTree, Taglist, CTags, CScope, Source Explorer等及简单的安装使用说明。 长期使用后可比Source Insight. " syntax highlighting hi Comment cterm=NONE ctermfg=DarkRed gui=NONE guifg=...

    vim使用进阶:vim使用技巧、配置、命令和插件

    本文介绍了如何使用Exuberant ctags生成tag文件以及在vim中如何使用tag文件进行跳转、查找等操作。还简要介绍了tag文件的格式,在后面介绍的Lookupfile插件中,会利用tag文件便捷的查找、打开文件。 vim使用进阶: ...

    vim配置,包含自己写的说明,很全,很好用

    c.vim, gtk-vim-syntax.tar 是用于 vim 中用于 gtk ...另外建议安装 ctags 与 cscope, 通过它们我们可以在 vim 中进行函数跳转或反向索引等操作, 便于阅读代码. 这些工具建议通过 debian/ubuntu 的 apt 机制自己安装

    我的VIM Plugin及配置文件-New

    VIM Plugin,DOC及配置文件打包。...NERDTree, Taglist, CTags, CScope等及简单的安装使用说明。 长期使用后可比Source Insight. Reference: http://cscope.sourceforge.net/cscope_vim_tutorial.html

    vim插件集合

    vim插件集合,内有ctags5.7,grep,winmanager,supertab,cscope,taglist

    ubuntu下的vim插件

    ubuntu下的vim插件集合,包括了cscope、ctags、c-support、taglist、minibufexpl等常用的插件,只要运行文件夹下的Install.sh脚本就能自动安装。

    vim插件和配置 for Linux 自动补全 IDE

    里面的vim插件已经包含了taglist,omnicppcomplete等插件,无需再下载,详细的配置参考.vimrc,注意快捷键使用即可。有什么不喜欢和bug的地方,自行调整.vimrc。ctags命令工具还是要下载安装的。 1. 安装ctags和...

Global site tag (gtag.js) - Google Analytics