1

There are many question regarding this on SE and various solutions have been provided on how to access system clipboard on various platforms. I ssh to various machines and on some platforms, my clipboard and vim stop playing well (specially over shh).

Is there a plugin to which makes vim access the system clipboard on almost all Linux, MacOSX, and puTTy (with ssh -X) ?

1
  • ssh -Y might work for you
    – Mass
    Jan 7, 2018 at 1:18

1 Answer 1

2

I've not heard of such a plugin (doesn't mean it doesn't exist). But I can lay out an alternative approach...

Instead of dealing with multiple systems and their disparate clipboard configurations use your local vim (+netrw) to edit remote files. Since you mention accessing remote systems with ssh then vim can use scp, for one. Let's say you want to update a text file in a remote home directory...

:Nread scp://my.name@example.com/~/file.txt

Or even...

:e scp://my.name@example.com/~/file.txt

Works from the command line, too. ($ vim scp://etc).

Now you can cut and paste to your heart's content using just the local clipboard.

Other protocols are available including these (:h netrw-read for complete list):

:Nread "ftp://[user@]machine[[:#]port]/path"    uses ftp w/ <.netrc>
:Nread "http://[user@]machine/path"             uses http
:Nread "rsync://[user@]machine[:port]/path"     uses rsync
:Nread "scp://[user@]machine[[:#]port]/path"    uses scp

More remote editing tips


If your workflow is more along the lines of impromptu use of vim while you're doing work on the command line of a remote machine then check out out bcvi. Install this standalone script on a remote machine and then when you do vi file.txt on the remote (e.g. during an ssh session) your local [g]vim will open the remote file automatically using the same underlying mechanism as described above.

Some outside the box thinking for you.

1
  • bcvi looks very promising. Thanks for mentioning it.
    – Dilawar
    Jan 7, 2018 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.