1

Yanked text with y, then v select some text, paste with p, but nothing happens.

1

Pasting over a visual selection should work exactly once. When pasting a second time the visual selection from the first time will be pasted instead of the yanked text. (At least that's what happens in version 8.1.1779, but ISTR that in earlier versions pasting did not work; just like you describe. This might have been changed with 8.0.140, but I can't check this right now.)

When you yank a text without giving a target register the text will be stored in register "0. The default register "" then points to register "0. Now you select some text. When you paste over the selection it is first deleted and stored in register "1 (or "- for small deletions). Then the contents of the default register is inserted. At some time during the paste action the default register will be updated to point to register "1 (or "-) because of the deletion.

Depending on when the update of register "" happens you will either put the contents of register "0 (the yank register) or "1/"- (the (small) delete register). You can state explicitly which register to paste by using "0p or "0P.

  • 1
    "0p is working. I'm using 8.0.1608. If I start vim with default setting, p is working. So something is wrong with my environment. Not sure how to debug, maybe need to gradually comment out some settings and try. – Fisher Jul 31 at 13:42
  • 1
    Found reason it's causing by set clipboard=unnamed. – Fisher Jul 31 at 13:53
  • 1
    I shall use set clipboard=unnamedplus. – Fisher Jul 31 at 14:06
  • 1
    @Fisher Can you check if you have a mapping for p and where it was set with verbose vmap p? – Jürgen Krämer Jul 31 at 14:07
  • 1
    Forgot I have this mapping: xnoremap p pgvy. – Fisher Jul 31 at 15:45

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.