39

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.

4
  • 4
    Are you in insert mode for vi? Using putty? Try shift+insert.
    – jordanm
    Jan 24, 2014 at 0:24
  • shift+insert and then what? yes, putty
    – frickskit
    Jan 24, 2014 at 0:26
  • 2
    Putty should have the standard clipboard facilities (copy, paste, cut...) somewhere in the window menu - have you tried that? Remember to have vi in insert mode when you do that as jordanm suggested. It is also usually a good idea to :set paste when pasting anything into vim. Also check PuTTY's selection options: configuration -> Window -> Selection (see e.g. codeweblog.com/upload/c/h/…)
    – peterph
    Jan 24, 2014 at 2:44
  • Why did Microsoft do such a poor job integrating ssh into its system? It's a stick in the eye to all of us who log into servers to do work. Aug 16, 2020 at 21:47

11 Answers 11

37

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)

3
  • This didn't seem to work for me?
    – Grayscale
    Feb 12, 2020 at 18:41
  • @Grayscale manufacturers can configure Windows machines in various ways, so there is less consistency than Mac's. Sometimes the Fn key must also be pressed in order to enable the Insert functionality on that key. Or maybe another combination works. Fortunately, in the latest versions of Win 10, standard methods, such as menus from a mouse right click, works now, in many places it previously did not. May 30, 2020 at 0:41
  • In the case that a secondary key is redwood to access the Insert functionality, sometimes the manufacturer will provide a way to swap out which set of function key functionality is default, and which requires the fn key. I don't remember the details, but one laptop I had allow me to change the default. I think it was in the boot menu? I don't think is was bios. Anyway, it wasn't an obvious, often accessed location, but once I saw the documentation online, it was super easy to do. Jul 4, 2020 at 18:38
7

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".

5

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

4
  • Right-click has already been mentioned
    – Jeff Schaller
    Nov 5, 2019 at 13:06
  • This doesn't seem to work for me.
    – Grayscale
    Feb 12, 2020 at 18:45
  • For me right click enters visual mode and does nothing to copy
    – queezz
    Sep 29, 2021 at 9:23
  • This worked for me, but having to switch to mouse to paste is a little inconvenient (mouse drag + Ctrl-C works though). Was hoping there would be a keyboard shortcut that would work for pasting. The others I tried didn't work, eg Shift-Ins just inserts raw text into Vim. On my Windows 10 machine (processor too old to upgrade), this is a problem, but using the Terminal in Windows 11 running PowerShell, I don't have the same issue and can just Ctrl-C/V.
    – Cloud
    Jan 27, 2022 at 8:46
4

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.

5
  • 2
    when I ctrl+right click the paste button is grayed out! (and just right click doesn't do anything).
    – frickskit
    Jan 24, 2014 at 13:19
  • @frickskit are you sure the text you want to paste is in the clipboard? Try pasting it in notepad to be sure. This always worked for me. Jan 24, 2014 at 14:45
  • My problem is 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.
    – frickskit
    Jan 24, 2014 at 15:39
  • @frickskit ah... You said putty earlier... I'm not familiar with PuttyTray Jan 24, 2014 at 17:45
  • yeah, my bad -- didn't think they would be different.
    – frickskit
    Jan 25, 2014 at 21:30
3

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...

2

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
1
  • Welcome to the site, and thank you for your contribution. Please note however, that in the current form your post looks like an error analysis, which is off-topic on this site, where the idea is to have one question and one or more "definitive" solutions. Please revise your post in case it was intended as a full-fledged answer to prevent this kind of misunderstanding, or add the key content as a comment to the question rathern than posting it as an answer.
    – AdminBee
    Nov 11, 2020 at 12:00
2

Hold shift while pressing right-click to paste into vim from powershell over an ssh connection.

1

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.

2
  • This doesn't seem to work for me.
    – Grayscale
    Feb 12, 2020 at 18:43
  • Ctrl+Shift+V did work for me. Aug 24, 2022 at 18:01
0

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.

2
  • 1
    Right-click has already been mentioned
    – Jeff Schaller
    Nov 5, 2019 at 13:06
  • Thanks @JeffSchaller, I know, hence why I said in the beginning of my post. I mentioned it because it wasn't explicitly made clear to anyone in detail :)
    – Kevdog777
    Nov 5, 2019 at 14:22
0

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.

1
  • 2
    I think you read the question backwards :)
    – JamesL
    Jan 30, 2020 at 0:13
0

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.

You must log in to answer this question.

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