我想在项目的子目录中自动加载cscope.out
,所以我在.vimrc
中添加了这些脚本,如下所示:
set cscopequickfix=s-,c-,d-,i-,t-,e-
if has("cscope")
set csprg=/usr/bin/cscope
set csto=1
set cst
set csverb
set cspc=3
"add any database in current dir
if filereadable("cscope.out")
cs add cscope.out
"else search cscope.out elsewhere
else
let cscope_file=findfile("cscope.out", ".;")
"echo cscope_file
if !empty(cscope_file) && filereadable(cscope_file)
exe "cs add" cscope_file
endif
endif
endif
它起初有效。但每当我尝试做的时候:
:cs find c [tag]
搜索结果将显示在QuickFix列表中,但无法打开包含结果的文件。
任何建议都将受到赞赏。
答案 0 :(得分:3)
如果添加cscope.out
,请确保设置正确的路径前缀。否则它会显示结果但无法加载文件。
示例:
cs add ../cscope.out ../
因此您应该将脚本更改为
...
else
let cscope_file=findfile("cscope.out", ".;")
let cscope_pre=matchstr(cscope_file, ".*/")
"echo cscope_file
if !empty(cscope_file) && filereadable(cscope_file)
exe "cs add" cscope_file cscope_pre
endif
...