Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to have Vim reconnect to a different X server?

Tags:

vim

xserver

I am using Vim inside tmux over an ssh connection on a remote machine. I access the remote server from several locations including work and at home. This usually causes stale $DISPLAY variables and associated problems, most of which I have resolved except for one:

If I have a vim session already opened, is there a way to change which X server it is connected to without closing and re-opening it? I need to be able to do this so I can copy snippets of text from Vim using the X clipboard. I normally keep multiple vertical splits, linebreak and line numbers on, so doing this through tmux is usually a giant hassle and would prefer to do it with vim.

like image 818
Yubin Kim Avatar asked Nov 05 '25 11:11

Yubin Kim


1 Answers

You can use xpra to display a running X11 program (specifically, vim) on different X11 servers.

This program functions for X11 programs like GNU screen or tmux do for terminal programs. xpra provides an X server for running programs and itself acts as an X client for the X server for the user's display.

You mention that you are running vim through tmux; you should maybe run vim outside of tmux and use xpra directly. As far as I know the program has to be run through xpra from the start.

like image 105
Gavin Smith Avatar answered Nov 07 '25 15:11

Gavin Smith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!