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



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