3

Windows 10 has a clipboard history which can be accessed using WIN+V it has a recent history of all your copy and paste. When using this in VIM and trying to paste from it doesn't work it acts like nothing happens. Wondering if there's a way to make it usable in VIM. The alternative is opening up a notepad and just windows copying from there which is just extra steps.

4
  • 1
    Welcome to Vi and Vim! – D. Ben Knoble Jan 23 at 16:21
  • On my laptop, WIN+V works as expected, pasting into Vim 8.0 (in Insert Mode) in Windows Terminal - Ubuntu and Windows Terminal - OpenSUSE. (In Normal Mode, it ignores what I paste until it hits one of A, a, I, i, O, o, R, S, s; then pastes the remainder.) When I try to do it in WSL - Ubuntu and WSL - OpenSUSE (in Insert Mode or in Normal Mode), Vim enters Visual Block Mode. In GVim 8.2, in Insert Mode ⊞v prints a caret ^, and in Normal Mode it enters Visual Block Mode, allowing me to select a rectangular block of text. Curious. – m_mlvx Jan 25 at 1:18
  • 1
    Win-V (aka ⊞v) should have no effect except to open the clipboard history window. Windows intercepts Win-V before it reaches a window. It's when you click on a row in the history window that some keystroke is sent to the window from which you entered Win-V. And that keystroke is as I describe in my answer: Ctrl-V or similar. That one can have the kind of effects you describe. Are you sure you have this feature enabled? – B Layer Jan 26 at 11:02
  • I did not have ⊞v enabled at first -- I seem to remember disabling "clipboard history" a few years ago, because, if my memory is correct, ctrl-v (back then) invoked the clipboard history, and I hated getting lots of irrelevant options (instead of what was most recently in the clipboard). But, I had to turn it on to try it and get the results I described above. Win10 helpfully pops up a message about enabling it, if you press ⊞v with clipboard history disabled. Now that it's on, I'll probably keep it enabled. – m_mlvx Jan 26 at 16:47
3

It looks like selecting something from that window leads to Windows doing Ctrl+V in an attempt to paste. That, of course, doesn't mean the same thing in Vim. However, if you have things properly set up to catch clipboard text in register * (see :h 'clipboard') then all you'd need to do after clicking an item in the window is hit p in Vim. (If that doesn't work see if "*p does.)

I just tried it and p does work for me.

(There are ways to make Ctrl-V do a put in Vim but that's a bit more obtrusive.)

Update: I was playing around a bit with this and it appears to be a little smarter than just Ctrl-V pasting everywhere. For instance, in my mintty terminal that I use for Cygwin it successfully pastes but it can't be using Ctrl-V as that does nothing. I do have both Shift+Ins and Ctrl+Shift+V set up to act like Ctrl-V, though, and it seems that it detected one of these.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.