每次使用cscope时,即使有多个结果,它也会自动跳转到第一个结果。
我想获得匹配结果的列表,因此我可以从中选择一个。到目前为止,我没有为.vimrc中的cscope设置任何内容。
我怎样才能做到这一点?
$vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 4 2012 04:25:35)
Included patches: 1-429
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by buildd@
Huge version without GUI. Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path
+find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv
+insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape
+mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse
+mouse_xterm +mouse_urxvt +multi_byte +multi_lang -mzscheme +netbeans_intg
+path_extra -perl +persistent_undo +postscript +printer +profile +python
-python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent
-sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
-toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
-xterm_clipboard -xterm_save
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions
答案 0 :(得分:0)
您在问题中包含的版本信息通常是无用的:$ vim --version
的完整输出是有用信息(补丁级别,启用/禁用功能......)。
Cscope默认显示可能匹配的列表,因此如果您的~/.vimrc
中没有与cscope相关的选项,您想要的行为就会发生。
在我当前的JavaScript文件中,例如,命令:cs f 0 addClass
显示了3个项目的列表,功能定义和两个调用。
您确定~/.vimrc
中没有任何与cscope相关的内容吗?您确定您的查询有多个匹配项吗?在直接运行cscope TUI时会得到多个匹配项吗?
答案 1 :(得分:0)
原因在于我在https://github.com/brookhong/cscope.vim使用了另一个版本的cscope.vim,它改变了这些功能。
答案 2 :(得分:0)
我知道问题的两种解决方案:
cscope
" Run native cscope and close automatically opened buffer
func s:Run_cscopeWithCloseBuffer(query, pattern)
" Save info about opened buffers
let bufinfo = getbufinfo({'buflisted':1})
try
" run cscope
exe 'cs find ' . a:query . ' ' . a:pattern
" If query populates quickfix
if a:query !=# 'g' && a:query !=# 'f'
" save opened buffer number
let opened_bufnr = bufnr('%')
" open quickfix window, switch to previous buffer
" and go back to quickfix
silent! botright copen
exe 'wincmd p'
exe "normal \<C-O>"
exe 'wincmd p'
" check if atomatically opened buffer was opened before
let noclose = 0
for buf_i in bufinfo
if opened_bufnr == buf_i.bufnr
let noclose = 1
break
endif
endfor
" Close atomatically opened buffer
if !noclose
exe 'bdelete ' . opened_bufnr
endif
endif
" If cscope has not found any matches
catch /^Vim(cscope):E259:/
echo 'No matches found for cscope query ' . a:query . ' ' . a:pattern
catch
echo v:exception
endtry
endfunc