简体   繁体   中英

How do I paste from PuTTY into Vim 8.0?

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?

图片

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.

我通过关闭鼠标模式解决了这个问题。

:set mouse=

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM