是否有一个配置条目可以放置在我的 .vimrc 中,它与传递 -X
的效果相同运行 vim 时标记。
提供一些上下文:
我最近发现我在屏幕 (tmux) session 中的 vim 启动时间非常长(约 6 秒)
使用 vim --startuptime
标志,很明显问题是由于连接到 X 服务器以设置 X 剪贴板。
运行 vim -X
修复了我缓慢的启动时间。我更愿意修改我的 .vimrc,而不是创建一个 bash 别名来解决这个问题。
最佳答案
您可能需要查看 clipboard
设置 ( :help 'clipboard'
)。以下是 Gary Johnson ( source , via web.archive.org ) 的建议。
你可能想在你的 .vimrc 中设置“剪贴板”,这样你就不会
必须一直使用 -X。在我的情况下,我在一个
我从其他各种机器登录的机器,其中一些
即使他们没有 X 服务器,也设置了 $DISPLAY。这是
我的 .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
变量)。
关于vim -X 标志为 .vimrc 条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10718573/