cscope数据库生成脚本

#!/bin/sh
find $(pwd) -name "*.h" -o -name "*.c" -o -name "*.cc" > cscope.files
cscope -bkq -i cscope.files
ctags -R


将以上代码保存为.sh文件,例如cs.sh,然后终端中修改其属性,增加执行属性;


将以下内容增加到 .vimrc 内

" tags 设置
set tags=tags;
    set autochdir


if has("cscope")
    set csprg=/usr/bin/cscope
    "指定用来执行 cscope 的命令
    set csto=1
    "先搜索tags标签文件,再搜索cscope数据库
    set cst
    "使用|:cstag|(:cs find g),而不是缺省的:tag
    set nocsverb
    "不显示添加数据库是否成功
    " add any database in current directory
    if filereadable("cscope.out")
        cs add cscope.out
    "添加cscope数据库
    endif
    "显示添加成功与否
    set csverb
endif

:set cscopequickfix=s-,c-,d-,i-,t-,e-

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>


运行cs.sh,此后可以参考其他的教程~~

你可能感兴趣的:(c,数据库,脚本,database,终端,tags)