TransWikia.com

Copy/paste into SSH'd VIM from local (Windows) clipboard

Unix & Linux Asked by frickskit on December 17, 2021

I would like to copy from a local machine and paste into vim on a remote box which I am SSH’d into.

That’s it.

I have tried "+p and "*p, mouse middle-clicking, and a couple other things to no avail 🙁

Also acceptable (though less convenient) is to just skip vim and pipe clipboard into file.

My problem was that I am using PuttyTray and not Putty, when I tried to do the same thing in Putty it worked — I didn’t think there would be a problem with that.

10 Answers

I found that set mouse=n allowed me to still click my mouse inside of nvim, but also pastes from an ssh terminal into the machine running vim.

Answered by Gloat on December 17, 2021

From my windows computer, I connect with Putty to 2 different machines:

  1. Machine: Ubuntu system; pasting with mouse-right-click into Putty window

    • OK: works at linux console
    • OK: works at VIM editor
  2. Machine: firewall system with a basic linux system; pasting with mouse-right-click into Putty window

    • OK: works at linux console
    • FAILED: doesn't work at VIM editor
      • if I am at mode -- INSERT --, after mouse right click the VIM is in mode -- VISUAL --
      • so it might be a "feature" somehow that we all didn't expected and don't want?!
    • OK: Shift+Insert works

My conclusion for now: it's

  • not a client setting thing, because it's depending on the remote server that I connect to
  • not a Putty application thing, because it's both times the same software
  • not a Putty configuration thing, because I use the same session configuration for both remote servers (changing the Putty session options didn't worked for me)
  • a remote server thing, that VIM is either
    • configured differently between distros or
    • a special package is required to be installed and enabled and the distros provide a different set of installed packages

Answered by Jochen on December 17, 2021

This worked for me:

  1. Right click in command prompt window's title area.

  2. Click "Properties".

  3. In "Options" > "Edit Options", click the checkbox next to "Use Ctrl+Shift+C/V as Copy/Paste".

Answered by iRector on December 17, 2021

I am using the Windows Subsystem for Linux to SSH and could not get anything to work for pasting into Vim directly (including right-click). Pasting into the terminal outside of vim did work though (with right-click), so I ended up just doing

echo "<right-click to paste>" >> filename.txt

then vim filename.txt and putting the pasted text where I wanted it. Annoying, but better than nothing at least...

Answered by Grayscale on December 17, 2021

This is what I do.

Inside of Linux SSH session: type cat nameoffile highlight text with mouse, right click it and select copy.

Then on Windows application such as Word: Right click and select paste.

Answered by kerafyrm kerafyrm on December 17, 2021

I see that this post has already been answered, but as a further option; I use PuTTy and my local machine is Windows 10.

If I copy some text from my local machine, all I need to do is to right mouse click into the PuTTy terminal window, and this will paste my clipboard there.

It doesn't matter if you are using vim, vi or nano, etc. it will still work, as this is a PuTTy terminal.

Answered by Kevdog777 on December 17, 2021

If you are using windows 10 ssh on the command line all you need to do is right-click the mouse.

Answered by Ainsley on December 17, 2021

These days, I am using WSL (Ubuntu 18 TLS) in a Windows 10 machine instead of PuTTY for SSH and I use Vim.

I had troubles copying code from Windows 10 to paste in the remote server. Ctrl+Shift+V did not work or any other method.

My solution is: copy text from a window, then move to the Ubuntu terminal, then change Vim to insert mode (insert) then use the right click of the mouse.

Answered by Jae Mun Choi on December 17, 2021

On my windows laptop, pasting into remote vim, this is the only thing I could get to work:

Ctrl+C was fine for copying.. but I needed Shift+Insert to Paste !

(A good reason to get a laptop where Insert can be accessed without pressing a secondary key)

Answered by SherylHohman on December 17, 2021

Enter insert mode in vim (i) and you can right click on the putty window to bring up a menu that has a paste command. Also an option in the menu bar. Works for me from windows.

Putty doesn't copy the the contents of the windows clipboard to the remote computer's clipboard. It basically virtually enters them as if you were typing the characters in the clipboard.

Answered by OrganicLawnDIY on December 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP