created February 11, 2011 · complexity basic · author Dorserg · version 7.0
By default, Cscope script adds
cscope.out from Vim's current directory and from
$CSCOPE_DB. However, if you start Vim from say
cscope.out is at
cscope.out won't be loaded automatically.
For ctags, there is a nice trick: with the command
:set tags=tags;/ Vim will look for tags file everywhere starting from the current directory up to the root.
This tip provides the same "autoloading" functionality for Cscope. Just add the following to your vimrc:
function! LoadCscope() let db = findfile("cscope.out", ".;") if (!empty(db)) let path = strpart(db, 0, match(db, "/cscope.out$")) set nocscopeverbose " suppress 'duplicate connection' error exe "cs add " . db . " " . path set cscopeverbose " else add the database pointed to by environment variable elseif $CSCOPE_DB != "" cs add $CSCOPE_DB endif endfunction au BufEnter /* call LoadCscope()