2012-05-23 23 views
2

有沒有一個配置條目我可以放在我的.vimrc中,這將實現與運行vim時傳遞-X標誌相同的配置條目。vim -X標誌爲.vimrc條目

提供一些背景: 我最近發現,在屏幕(TMUX)會話我的vim啓動時間非常長(〜6秒)

使用vim --startuptime標誌,很顯然,這個問題是由於連接到X服務器以設置X剪貼板。

運行vim -X已經確定我的啓動時間很慢。我寧願修改我的.vimrc,而不是創建一個bash別名來解決這個問題。

回答

6

您可能需要查看clipboard設置(:help 'clipboard')。接下來是Gary Johnson的建議(source)。


讓你不 你可能要設置在.vimrc「剪貼板」必須使用-X所有的時間。在我的情況下,我在一臺 機器上使用vim,該機器從其他各種機器登錄到其中,其中一些 具有$ DISPLAY集,即使它們沒有X服務器。這裏是 什麼我在我的.vimrc:

" Prevent vim from trying to connect to the X server when connecting 
" from home, which causes a startup delay of about 14 seconds. I 
" usually connect from home via screen. 
" 
"set clipboard=autoselect,exclude:cons\\\|linux\\\|screen 
" 
" Using $DISPLAY instead of 'term' should be more reliable. It avoids 
" the problem of starting vim without first starting screen and allows 
" screen to be used locally without losing vim's X features. 
" 
if $DISPLAY =~ '\(\(cos\|scs\)\d\+nai\d\+\)\|\(spkpc\d\+\)\|\(tc-garyjohn\)' 
set clipboard=autoselect,exclude:.* 
endif 

(做到這一點你需要調整if $DISPLAY行自己$DISPLAY變量相匹配的通知)。

+1

對於cygwin:set clipboard = autoselect,exclude:cons \\\ | linux \\\ | screen \\\ | rxvt \\\ | cygwin。謝謝! – Kurt

+0

來源鏈接已死亡。 – akhan

1

只需添加到您的的〜/ .vimrc

set clipboard=exclude:.* 

做這個主要是你的root用戶。其他用戶應該很好地連接$DISPLAY和剪貼板。

+0

這將停止在root下運行啓用了GUI的vim實例的'No protocol specified'錯誤。 –