Vim Tips Wiki
(tweak TipProposed template + minor manual clean)
Line 33: Line 33:
   
 
==Comments==
 
==Comments==
  +
In the Vim73, it can't work, in my PC, it seems need to be changed to
  +
" set nocscopeverbose .....
  +
...
  +
exe "cs ....
  +
set cscopeverbose
  +
...."

Revision as of 08:56, 10 August 2011

Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).

Please use new tips to discuss whether this page should be a permanent tip, or whether it should be merged to an existing tip.
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 ~/proj/src/a/b/c/, while cscope.out is at ~/proj/src/, that 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 nocsverbose " suppress 'duplicate connection' error
    exe "cs add " . db . " " . path
    set csverbose
  endif
endfunction
au BufEnter /* call LoadCscope()

See also

Comments

In the Vim73, it can't work, in my PC, it seems need to be changed to " set nocscopeverbose .....

 ...
 exe "cs ....
 set cscopeverbose

...."