VS code VIM extension copy and paste

Rather than rebinding, you can simply stop the vscodevim extension from handling Ctrl-C and Ctrl-V entirely, which then allows VSCode to handle them natively. This can be done by placing the below code in the extension's settings.json file:

"vim.handleKeys": {
    "<C-c>": false,
    "<C-v>": false
}

This will work regardless of which mode you're in, and will perfectly accommodate the system clipboard. I'm not sure if the <C-c> is necessary, but the <C-v> definitely is, as <C-v> is the standard Vim chord to enter visual block mode.

As an aside, your rebind method is perfectly valid; it just requires a bit more code:

// For visual mode
"vim.visualModeKeyBindings": [
  {
    "before": ["<C-c>"],
    "after": ["\"", "+", "y"]
  },
  {
    "before": ["<C-v>"], 
    "after":  ["\"", "+", "p"]
  }
],
// For normal mode
"vim.normalModeKeyBindings": [
  {
    "before": ["<C-c>"],
    "after": ["\"", "+", "y"]
  },
  {
    "before": ["<C-v>"], 
    "after":  ["\"", "+", "p"]
  }
]

In the latest version of VS code (on Linux, flatpak version, 1.68.1) and vim addon (at the time of writing), this can be easily enabled by ticking the "Vim: Use System Clipboard".

Note: You can open settings by Ctrl+, then search for 'vim clipboard'

enter image description here


Vim - extension config flag

Tick the checkbox in settings by searching for "vim clip".

or

Paste the following inside your VS Code's settings.json file:

"vim.useSystemClipboard": true

Access VSCode settings.json file:

  1. Press Ctrl + , (or go to File > Preferences > Settings)
  2. Click the icon: "file with arrow" in the top right corner

VSCode access settings json file


Settings found in VSCodeVim/Vim repository quick-example