Is there a config entry I can place in my .vimrc which will achieve the same as passing the -X
flag when running vim.
To provide some context: I recently found that my vim startup time in a screen (tmux) session was extremely long (~6 seconds)
Using the vim --startuptime
flag, it is clear that the issue is due to the connection to the X server in order to setup the X clipboard.
Running vim -X
has fixed my slow startup time. I would prefer to modify my .vimrc, rather than creating a bash alias to solve this.
You may want to take a look at the clipboard
setting (:help 'clipboard'
). What follows is a recommendation from Gary Johnson (source, via web.archive.org).
You may want to set 'clipboard' in your .vimrc so that you don't have to use -X all the time. In my situation, I use vim on a machine that I log in to from various other machines, some of which have $DISPLAY set even though they don't have an X server. Here is what I have in my .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
(Do notice that you'll need to tweak the if $DISPLAY
line to match your own $DISPLAY
variable).
Just add to your ~/.vimrc
set clipboard=exclude:.*
Do this mainly to you root user. Other users should work fine connecting the $DISPLAY
and clipboard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With