Vim 禁用cscope自动跳转
每次我使用cscope时,即使有多个结果,它也会自动跳转到第一个结果 我想获得匹配结果的列表,以便从中选择一个。到目前为止,我没有为.vimrc中的cscope设置任何内容 我怎样才能做到这一点Vim 禁用cscope自动跳转,vim,cscope,Vim,Cscope,每次我使用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.d
$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
您在问题中包含的版本信息通常是无用的:$vim-version的完整输出中有用的信息是补丁级别、启用/禁用的功能 Cscope默认显示一个可能匹配的列表,因此如果~/.vimrc中没有与Cscope相关的选项,那么您想要的行为就是应该发生的 例如,在我当前的JavaScript文件中,命令:cs f 0 addClass显示了一个包含3项、函数定义和两个调用的列表
你确定你的~/.vimrc中没有任何与cscope相关的东西吗?您确定您的查询有多个匹配项吗?直接运行cscope TUI时是否有多个匹配项?原因在于我在这里使用了另一个版本的cscope.vim,它改变了功能。我知道问题的两种解决方案: 在中实现时使用外部shell命令cscope 立即关闭自动打开的缓冲区。
在my.vimrc中,cscope的唯一内容是一些关键的nmap。我确信我的查询有多个匹配项。您使用什么命令以及~/.vimrc中有什么映射?我向您保证,我所做的只是:cs add cscope.out,cs find g multi_matches_name。vimrc中的nmap用于cs find命令。
" 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