13
votes

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
Default settings have been changed. Read :h defaults.vim how to override those settings. (Basically you would need to create a .vimrc file)Christian Brabandt

3 Answers

25
votes

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.

6
votes

I solved this problem by turning off mouse mode.

:set mouse=
1
votes

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