I am using vscode + vim. Consider a common scenario where I have to yank/delete some text from one place and replace it with some text anywhere else. But as I need to replace I have to first delete the other text. This results into lost of the previously deleted text.

The solution I thought of it that I can map some key to move contents of " register to register a so it gets saved and whenever I need it I can use <leader> + p to paste it. <leader> + p is mapped to "ap.

I figured out how to move content between registers using let but the issue is that vscode vim doesn't support that yet. It is saying

:let is not implemented yet PRs are welcomed.

Is there any other way I can do this? Is there any alternative for let for vscode vim or does anyone have any better solution for this issue.

  • Hi Ali, I tempted to provide you a solution. Did it solve your problem? Do you have still open problem after trying the proposed solution? Commented Jul 15, 2022 at 9:29

2 Answers 2


A solution to your use case is to:

  1. yank the text you want (using the y command)
  2. select the text you want to replace in visual mode (e.g.: viw, vi" and their friends)
  3. past the text you have copied (using the p command)

Remark: If you repeat the operation, because the " buffer has been changed to the content you have replaced in the first past operation it will lead to a behavior you may not like.

To overcome that problem (of the second replacement) a usual trick, that works on VsCodeVim too, is to map p into pgvy.


  • p do the past
  • gv reselect the pasted text
  • y restore the " register to the pasted content.

Here is the corresponding extract from the VSCode settings: settings.json to have it in VsCode:

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

Use the replace plugin that is available with vscodevim.

use gr[motion] to replace the selection.

e.g: use


to replace the current word at cursor with the clipboard content.

  • Thanks. Can you give more details how to add it because I can't find any replace plugin with vscodevim
    – Maheer Ali
    Commented Dec 15, 2022 at 7:37
  • see the settings. or add this settings in settings.json: "vim.replaceWithRegister": true, @MaheerAli Commented Dec 15, 2022 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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