为了技术,我不会停下学习的脚步,我相信我还能走二十年。
分类:
2012-09-12 11:50:25
原文地址:cscope的用法 作者:kevin33643
#!/bin/sh find . -name "*.h" -o -name "*.c" -o -name "*.cc" > cscope.files cscope -bkq -i cscope.files ctags -R
:cs add cscope.out在vim命令行下执行:
:cs help cscope commands: add : Add a new database (Usage: add file|dir [pre-path] [flags]) find : Query for a pattern (Usage: find c|d|e|f|g|i|s|t name) c: Find functions calling this function d: Find functions called by this function e: Find this egrep pattern f: Find this file g: Find this definition i: Find files #including this file s: Find this C symbol t: Find assignments to help : Show this message (Usage: help) kill : Kill a connection (Usage: kill #) reset: Reinit all connections (Usage: reset) show : Show connections (Usage: show)
:cs f g do_fork
三,在VIM中使用cscope快捷键:
下面是我的.vimrc的配置,在该配置下,在使用vim打开文件时,默认加载当前目录下的cscope.out文件,如果没有的话就得用cs add命令手动加载了。另外也映射了查找的快捷键,如先按ctrl+\键,然后再按g键,将查找当前光标下关键字的定义出。
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" cscope setting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
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
nmaps :cs find s =expand(" ")
nmapg :cs find g =expand(" ")
nmapc :cs find c =expand(" ")
nmapt :cs find t =expand(" ")
nmape :cs find e =expand(" ")
nmapf :cs find f =expand(" ")
nmapi :cs find i ^ =expand(" ") $
nmapd :cs find d =expand(" ")
:tag xxx即可找到你想找的函数或是数据结构或是函数xxx