3

I'm using Ubuntu and vim. I can copy text from vim and paste it into another window by highlighting it in vim, then middle-clicking in the other window. This works fine when I'm on my local machine.

I can also copy into the system register by highlighting text and yanking to the system register. (For example, Shift-V JJ "+ y to go into linewise visual mode, highlight two lines, select the '+' register and yank.) It's then available to paste into other windows.

However, if I ssh into my web host, I can't do either of these. (They use some flavor of Linux - I think it's CentOS.)

In vim, if I type :version, my local version shows +xterm_clipboard, but the host's version shows -xterm_clipboard. I don't have sudo rights there.

Is there any way to be able to copy from their vim without getting them to tinker with the installation?

1
  • worth noting if you have/had +clipboard and you should have put into your question that you are talking about SSH being involved. 'cos without that you seem to be fine, so SSH / the SSH terminal you are using is crucial. It may barely even be a VIM issue. (And since it has been almost 10 years, maybe you can post the solution)
    – barlop
    Commented May 18, 2019 at 11:37

4 Answers 4

1

When you use ssh, you generally don't want the other computer to have access to your x session for security reasons. But if you do an ssh -X (again, you should understand the security implications) I think it should allow the remote shell to access the x windows clipboard.

2
  • SSH is encrypted; wouldn't any clipboard contents transferred also be encrypted? If so, isn't it then just a question of whether I trust the machine on the other end? Commented Apr 21, 2010 at 21:47
  • 1
    @GorillaSandwich, pretty much yes--trusting another machine can be tricky and dangerous. If you do anything sensitive, or if the sysadmin of the destination machine isn't security-aware, then your risk increases. Basically, the remote machine can run anything (including a keylogger) on your x session.
    – K Robinson
    Commented May 19, 2010 at 16:59
0

Can you run xcutset on their system ? That should be able to solve your problem. xclipboard is another option.

0

Check the mouse setting in vim :

:set mouse

From :help mouse :

When enabling the mouse in a terminal, copy/paste will use the "* register if there is access to an X-server. The xterm handling of the mouse buttons can still be used by keeping the shift key pressed.

In practice, if set to i or a, copypasting using the middle mouse button won't work, unless you keep the shift key pressed (but the shift key trick seems to work only from local to remote, not the other way round). If the mouse option is set to n, v, c or r, middle-button copypasting will work as intended (each option having other effects, obviously).

Therefore this vim command may fix your issue if you don't have other special mouse needs :

:set mouse=n

Note that mouse=n will also enable right-click paste.

0

Alternatively you might use scp to open the remote file in your local vim. Then do the cut and paste within the local vim. Here is the syntax:

:e scp://user@host//path/file.txt

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .