16

Scenario

From a Windows 10 Anniversary Update client ...

  • Open a web browser, copy / paste some text from a website (eg. GitHub)
  • Use PuTTY 0.67 to SSH to a Linux VM (eg. Ubuntu 16 Xenial Xerus)
  • Open a file in Vim
  • Hit i to change into Insert mode
  • Right-click to paste the clipboard contents

Issue

Unfortunately, when I right-click in the PuTTY session, rather than pasting clipboard contents, what's actually happening is that Vim is going from INSERT mode to (insert) VISUAL mode. I don't think I've ever seen anything like this before.

Question

Does anyone know why this is happening, and how I can paste my Windows client clipboard into the SSH / Vim session?

image

3 Answers3

31

It appears that this issue is due to a change in defaults for VIM version 8.0 and higher.

Previous versions had mouse mode turned off (mouse=), but the new default is mouse mode turned on (mouse=a).

There are 3 ways to deal with this situation:

  1. Adapt to it: With mouse mode turned on, the new way to paste is shift-right-click (at least in PuTTY)
  2. Change it: You can turn off mouse mode for your current VIM session by typing :set mouse= and <enter>
  3. Revert it: You can override the new defaults by calling VIM with the "C" switch (vim -C {filename}) and it will revert back to the Vi "compatible" settings for that session

Of course you can always add set mouse= to your .vimrc file to make it permanent. But that doesn't work for me because I hop around on too many different systems.

  • 2
    I think part of the issue is the PuTTY defaults - it sets TERM=xterm, but if you set TERM=putty, right-mouse works as expected. –  Jun 23 '17 at 01:38
  • maybe you should shift+rightclick twice, and select paste in the right click menu .just click once doesn't work – 傅继晗 Jan 23 '21 at 04:20
8

I solved this problem by turning off mouse mode.

:set mouse=
1

I faced the same problem

  1. You just need to change in the vmrc file vim $HOME/.vimrc
  2. set the following in the file set mouse-=a to .vimrc

It worked fine

Monika Singh
  • 169
  • 1
  • 8