JohnBeckett (talk | contribs) (move new comment into tip) |
|||
Line 21: | Line 21: | ||
if (!empty(db)) |
if (!empty(db)) |
||
let path = strpart(db, 0, match(db, "/cscope.out$")) |
let path = strpart(db, 0, match(db, "/cscope.out$")) |
||
− | set |
+ | set nocscopeverbose " suppress 'duplicate connection' error |
exe "cs add " . db . " " . path |
exe "cs add " . db . " " . path |
||
− | set |
+ | set cscopeverbose |
endif |
endif |
||
endfunction |
endfunction |
||
Line 33: | Line 33: | ||
==Comments== |
==Comments== |
||
+ | Thanks for the new comment. I put your text into the tip because the original seemed to be wrong (there were two changes: The original had <tt>nocsverbose</tt> and <tt>csverbose</tt>, but there is no such option. The correction changed these to <tt>nocscopeverbose</tt> and <tt>cscopeverbose</tt>. [[User:JohnBeckett|JohnBeckett]] 11:37, August 10, 2011 (UTC) |
||
− | |||
− | Thanks very much! |
||
− | In the Vim73, it can't work, in my PC, it seems need to be changed to |
||
− | |||
− | 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 |
||
− | endif |
||
− | endfunction |
||
− | au BufEnter /* call LoadCscope() |
Revision as of 11:37, 10 August 2011
Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).
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 nocscopeverbose " suppress 'duplicate connection' error exe "cs add " . db . " " . path set cscopeverbose endif endfunction au BufEnter /* call LoadCscope()
See also
Comments
Thanks for the new comment. I put your text into the tip because the original seemed to be wrong (there were two changes: The original had nocsverbose and csverbose, but there is no such option. The correction changed these to nocscopeverbose and cscopeverbose. JohnBeckett 11:37, August 10, 2011 (UTC)