85

I am using PuTTY to connect a remote host and editing via Vim. I meet a trouble when I try to paste something to Vim. That is, I copy something to the clipboard in my local host and want to paste it to the Vim on the remote host. How can I do that?

PS: I am using PuTTY! So, I open a Vim window via PuTTY. The very need is that I want to copy something in my local host and paste it to the Vim editor opened by PuTTY. That's all.

2
  • How exactly did you try to paste into vim? Is this of any help? stackoverflow.com/a/14225889/1945981 Commented Feb 15, 2014 at 12:38
  • I want to paste something to a putty vim window Commented Feb 15, 2014 at 12:49

5 Answers 5

163

Try with Ctrl + Shift + V or with middle click with a 3 button mouse.

Or Shift + Ins.

Source: https://superuser.com/questions/180043/paste-the-windows-clipboard-into-my-putty-session-using-only-the-keyboard

Sign up to request clarification or add additional context in comments.

2 Comments

Shift + Ins can paste what in clipboard to the putty window. But, my need is to copy what in clipboard to the vim editor opened by putty.
you need to be in the edit mode, not the visual mode, try pressing i and then Shift + Ins
70

You can insert text from your host’s clipboard by pressing the right mouse button (default setting) or by pressing Shift + Ins. Note that this has the same effect as entering every character manually. So if you are using auto indentation in vim, this will very likely screw up your code.

To fix that, you can do the following:

  1. Before pasting into vim, enable paste mode by entering :set paste.

  2. Press i to enter insert mode. The status bar should say -- INSERT (paste) -- now.

  3. Press the right mouse button to paste in your stuff. The auto indentation of vim should not happen.

    If this puts you into the -- (insert) VISUAL -- mode, exit out of it using Esc (putting you into the paste insert mode again), and try pasting it again while holding Shift using your right mouse button.

  4. Press Esc to leave insert mode, and disable paste mode using :set nopaste again.

You can change which mouse button is used to paste in PuTTY in the Window/Selection configuration page.

2 Comments

3rd step goes into -- INSERT (visual) --
What is happening when vim goes into -- (insert) VISUAL --? Why does holding Shift allow you to paste?
52

In Windows Subsystem for Linux it appears that you have to:

  1. i = to enter -- INSERT -- mode
  2. Shift-right-mouse-click = to paste

If you just right-mouse-click (i.e. without shift) then annoyingly all that happens is that the mode changes to -- (insert) VISUAL -- i.e. it doesn't paste anything.

5 Comments

I found shift, right-mouse-click also works for newer versions of Vim (8.0) when accessing through a putty session from Windows.
Or you can revert to previous behavior of right click to paste by adding set mouse-=a to your .vimrc (source)
This also works for the reverse problem, where Putty will not copy text from Vim with left-mouse-drag, but will with Shift left-mouse-drag
Shift-right-mouse-click works for me through PuTTY
Always worked without shift, hand no idea what's happening. Vim 8.1 requires shift+right-click and works like a charm!
4

To clarify the other answers, there are a couple ways to do this, depending on if Vim is running with mouse support. Lets assume its via some sort of terminal/Putty:

  • When not using mouse in remote Vim, right clicking will paste from local clipboard via Putty into remote Vim.
  • With mouse enabled in remote Vim, Shift + Ins will paste from local clipboard via putty into remote vim.
  • Ctrl + Shift + v will paste from local clipboard via native/*nixish/xterm into remote vim.
  • With mouse enabled in remote Vim, middle clicking will paste from remote clipboard into remote Vim.

Comments

-2

Copy-paste between Windows and PuTTY:

To copy from Windows and paste into PuTTY, highlight the text in Windows, press Ctrl + C, select the PuTTY window, and press the right mouse button to paste. To copy from PuTTY and paste into Windows, highlight the information in PuTTY and press Ctrl + V in the Windows application to paste it.

Copy-paste between two Vim sessions in separate PuTTY:

Highlight the information in the source PuTTY, and then press the right mouse button in the target PuTTY to paste.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.