VIM調用函數黑屏解決辦法

在.vimrc中有如下配置

map <F10> :call Do_CsTag()<CR>

function Do_CsTag()
    silent! execute "!ctags -R '.'"
    if(executable('cscope') && has("cscope") )
        silent! execute "!find -L `pwd` -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.java' -o -name '*.cs' -o     -name '*.cxx' -o -name '*.hxx'> cscope.files -o -name '*.hpp' -o -name '*.py'"    
	endif
    silent! execute "!cscope -bq"
    silent! execute "call Add_CsTag()"
endf 

function Add_CsTag()
    if filereadable("cscope.out")
        execute "cs add cscope.out"
        execute "set tags+=./tags"
    endif
endf



上面這段配置用來生成ctags,綁定到快捷鍵到F10
實際上,啓動VIM,按F10調用函數Do_CsTag,返回vim後,vim就變成黑屏了,但是內容都還在,光標覆蓋後才能顯示出來。
解決辦法:
在函數Do_CsTag最後加上這一句:

exec "redraw!"

刷新vim界面即可

修改後的配置如下:

map <F10> :call Do_CsTag()<CR>

function Do_CsTag()
    silent! execute "!ctags -R '.'"
    if(executable('cscope') && has("cscope") )
        silent! execute "!find -L `pwd` -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.java' -o -name '*.cs' -o     -name '*.cxx' -o -name '*.hxx'> cscope.files -o -name '*.hpp' -o -name '*.py'"    
	endif
    silent! execute "!cscope -bq"
    silent! execute "call Add_CsTag()"
	execute "redraw!"
endf 

function Add_CsTag()
    if filereadable("cscope.out")
        execute "cs add cscope.out"
        execute "set tags+=./tags"
    endif
endf



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章