What I want to do is to create a new cscope database based on different file types every time I open vim, and then automatically load cscope.out
I edit my .vimrc
, based on this article: how to auto load cscope.out in vim
But it only autoloads cscope.out
the second time I open vim, the first time I open vim, it always show no cscope connection
What should I change?
Here is my settings:
if !filereadable("cscope.out")
autocmd BufRead,BufNewFile *.py !find / -name "*.py" > ~/cscope.files; cscope -Rbq -i ~/cscope.files
autocmd BufRead,BufNewFile *.java !find / -name "*.java" > ~/cscope.files; cscope -Rbq -i ~/cscope.files
autocmd BufRead,BufNewFile *.c !find / -name "*.c" -o -name "*.h" > ~/cscope.files; cscope -Rbq -i ~/cscope.files
autocmd BufRead,BufNewFile *.cpp !find / -name "*.cpp" -o -name "*.hpp" -o -name "*.h" > ~/cscope.files; cscope -Rbq -i ~/cscope.files
autocmd BufRead,BufNewFile *.hpp !find / -name "*.cpp" -o -name "*.hpp" -o -name "*.h" > ~/cscope.files; cscope -Rbq -i ~/cscope.files
endif
" setting location of cscope db & cscopetag
let CSCOPE_DB="~/cscope.out"
if has("cscope")
" set csprg=/usr/local/bin/cscope
set csto=0
set cst
set nocsverb
" 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