Vim: Pasteboard(or register) will be rewrite if paste something on visual mode

Created on 24 May 2017  路  17Comments  路  Source: VSCodeVim/Vim

  • Click thumbs-up 馃憤 on this issue if you want it!
  • Click confused 馃槙 on this issue if not having it makes VSCodeVim unusable.

The VSCodeVim team prioritizes issues based on reaction count.


BUG REPORT

Environment:

  • VSCode Version:1.12
  • VsCodeVim Version: 0.7.1
  • OS: Win7

What happened:If you copy something to pasteboard like "aY, then select some new stuff in visual mode, then "ap, that's exact what you want, but if you do it again, "ap, the word selected in last visual mode will be pasted.

What did you expect to happen: In last version, things go well, what I keep in register[a] will be pasted, instead of replaced one.

How to reproduce it:Always happen.

areclipboard kinbug

Most helpful comment

This can now be fixed with:

    "vim.visualModeKeyBindingsNonRecursive": [
        {
            "before": [
                "p",
            ],
            "after": [
                "p",
                "g",
                "v",
                "y"
            ]
        }
    ],

https://github.com/VSCodeVim/Vim/pull/2726
https://github.com/VSCodeVim/Vim/pull/2744

All 17 comments

It's a result of this: https://github.com/VSCodeVim/Vim/issues/1280

It seems that we shouldn't be yanking to the specified register.

Well, I gotta change my method.

No, it's a valid bug. I was just noting the cause.

this behavior appeared since a few versions back, I thought it would be fixed soon since it's so buggy, now I'm still experiencing it, nobody use this function like this ???

@DrakeXiang The behavior seems to be correct for me,

@Chillee Ok, turns out this is the correct behavior in vim, didn't know that... so this is painful if you have to paste multiple times

@DrakeXiang Yeah :(

The right thing to do is to copy into a register with "ay. You can then paste without overwriting that register by selecting the text you're trying to replace and doing "ap. You can then simply use dot repeat to repeat that multiple times.

@Chillee this will be solvable by mapping p to "_dP only in visual mode. However that's not currently possible, so I made a new issue:

https://github.com/VSCodeVim/Vim/issues/2705

This can now be fixed with:

    "vim.visualModeKeyBindingsNonRecursive": [
        {
            "before": [
                "p",
            ],
            "after": [
                "p",
                "g",
                "v",
                "y"
            ]
        }
    ],

https://github.com/VSCodeVim/Vim/pull/2726
https://github.com/VSCodeVim/Vim/pull/2744

Seems the issue has come back...

@chibicode Thanks for the workaround. This should be standard though?

This is the expected behavior in vim. I have to override in in vimrc usually. I'm glad I know how to override it in vscode now as well, thanks!

Using the configuration from @chibicode does not work for me. Pasting overwrites the register still and consecutive pastes do not apply the initially yanked content. Any advice on this?

Maybe more info from my side. I figured I can select and paste the right content multiple times with ve and then p again, over and over again. My muscle memory wants to do that by simply repeating the last paste command I did using .. And this does not work. Any way to get this sorted?

@xh3b4sd This is expected behavior. From :help:

The previously selected text is put in the unnamed register. If you want to
put the same text into a Visual selection several times you need to use
another register. E.g., yank the text to copy, Visually select the text to
replace and use "0p . You can repeat this as many times as you like, the
unnamed register will be changed each time.

I understand that. My question is how I can just repeat the last paste. I am used to only type . again and the whole functionality is replicated. This is super easy and useful but I can't figure how to do that in vsCode. The complexity of ve"0p all over again kills my workflow and is so much more typing.

@chibicode 's workaround is okay, but I found that it doesn't work with multiline operations too well, as the document will scroll to the last yank. This is jarring to say the least. "0p can be a pain, but you can still use p if you like. The rebind fixes the multiline jumping, but note that it will not work with the repeat, . key.

"vim.visualModeKeyBindingsNonRecursive": [  
{  
            "before": [  
                "p",  
            ],  
            "after": [  
                "p",  
                "`",  
                "[",  
                "v",  
                "`",  
                "]",  
                "h",  
                "y",  
                "<Esc>"  
            ]  
        }  
    ],  
Was this page helpful?
0 / 5 - 0 ratings

Related issues

stefanoio picture stefanoio  路  3Comments

elithrar picture elithrar  路  3Comments

WangRongda picture WangRongda  路  3Comments

ACollectionOfAtoms picture ACollectionOfAtoms  路  3Comments

spinningarrow picture spinningarrow  路  3Comments