cscope是一款linux下的软件,其功能主要是用在阅读代码,堪称Windows下的Source Insight,但是配合vim使用,效率无与伦比。如需了解其具体使用,请先安装vim,然后在终端执行vim命令,并在命令行执行 :help cs 。以下提供测试过的配置。以下是 ~/.vimrc 中的配置。
set nu set shiftwidth=4 set tabstop=4 set softtabstop=4 set autoindent nmap <F2>s :cs find s <C-R>=expand("<cword>")<CR><CR> nmap <F2>g :cs find g <C-R>=expand("<cword>")<CR><CR> nmap <F2>d :cs find d <C-R>=expand("<cword>")<CR><CR> nmap <F2>c :cs find c <C-R>=expand("<cword>")<CR><CR> nmap <F2>t :cs find t <C-R>=expand("<cword>")<CR><CR> nmap <F2>e :cs find e <C-R>=expand("<cword>")<CR><CR> nmap <F2>f :cs find f <C-R>=expand("<cword>")<CR><CR> nmap <F2>i :cs find i <C-R>=expand("<cword>")<CR><CR> colorscheme desert if has("cscope") set csprg=/usr/local/bin/cscope set csto=0 set cst set nocsverb set cscopequickfix=s-,c-,d-,i-,t-,e- " add any database in current directory if filereadable("cscope.out") cs add cscope.out " else add database pointed to by environment elseif $CSCOPE_DB != "" cs add $CSCOPE_DB endif set csverb endif
有了以上配置,使用方法如下:
F2 + s Find this C symbol
F2 + g Find this definition
F2 + d Find functions called by this function
F2 + c Find functions calling this function
F2 + t Find this text string
F2 + e Find this egrep pattern
F2 + f Find this file
F2 + i Find files #including this file
让代码在键盘上飞起来吧!
end!
时间: 2024-10-02 22:17:56