VS code VIM extension copy and paste

vscode vim settings
vscode vim extension not working
vscode vim relative line numbers
vscode for vim users
vscode vim autoindent
visual studio vim
vim whichwrap vscode
vscode vim-multiple cursors

Is there a normal way to copy and paste in vs code using vim extension?

I've tried mapping VIM register commands to the shortcut commands I'm used to (ctrl + c for copying and ctrl + v for pasting), but the results are pretty weird and I'm not sure how to do this correctly.

While using vim the key bindings were quite simple, vimrc file:

map <C-c> "+y
map <C-v> "+p

Now I try to migrate those to vs-code by editting json.settings file:

{
    "vim.visualModeKeyBindings": [
        {
            "before": ["<C-c>"],
            "after": ["\"", "+", "y"]
        },
        {
            "before": ["<C-v>"], 
            "after":  ["\"", "+", "p"]
        },
    ], }

I want this to operate both in visual mode and in normal mode (for pasting), and be able to copy and paste from clipboard using these shortcuts.

How to do this correctly? Is there another way to do this?

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"]
  }
]

How to use clipboard for Vim in VSCode – Code Yarns ‍ , Visual Studio Code has a decent Vim extension. I use it by default and sometimes wish I could yank to and paste from the system clipboard. In this mode, you can run Vim commands and navigate through the file. To go back to normal mode from any other mode, just press the Esc key. Vim has its own terminology for copying, cutting, and pasting. Copy is called yank ( y ), cut is called delete ( d ), and paste is called put ( p ).

Vim

Paste the following inside your VSCode'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


Settings found in VSCodeVim/Vim repository quick-example

ctrl+v no longer pastes in insert mode · Issue #2646 · VSCodeVim/Vim, to paste text via ctrl+v when in insert mode. Recently however that shortcut has stopped working. Extension version: 0.11.6 VS Code version:  Vim emulation for Visual Studio Code. VSCodeVim is a Vim emulator for Visual Studio Code. 🚚 For a full list of supported Vim features, please refer to our roadmap. 📃 Our change log outlines the breaking/major/minor updates between releases. If you need to ask any questions, join us on Slack; Report missing features/bugs on GitHub.

Use vs code default copy, paste, delete line.

"vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": ["d","d"],
            "commands":["editor.action.deleteLines"],
            "when":"textInputFocus && !editorReadonly"
        },
        {
            "before":["y"],
            "commands":["editor.action.clipboardCopyAction"],
            "when":"textInputFocus"
        },
        {
            "before":["y","y"],
            "commands":["editor.action.clipboardCopyAction"],
            "when":"textInputFocus"
        },
        {
            "before":["p"],
            "commands":["editor.action.clipboardPasteAction"],
            "when":"textInputFocus && !editorReadonly"
        }
    ],
    "vim.visualModeKeyBindingsNonRecursive":[
        {
            "before":["y"],
            "commands":["editor.action.clipboardCopyAction"],
            "when":"textInputFocus"
        },
        {
            "before":["y","y"],
            "commands":["editor.action.clipboardCopyAction"],
            "when":"textInputFocus"
        },
        {
            "before":["x"],
            "commands":["deleteRight"],
            "when":"textInputFocus"
        },
    ]

https://github.com/VSCodeVim/Vim/#key-remapping https://code.visualstudio.com/docs/getstarted/keybindings

VSCodeVim/Vim: Vim for Visual Studio Code, VSCodeVim is a Vim emulator for Visual Studio Code. truck details page, which can be found in the extensions view of VS Code. useCtrlKeys, Enable Vim ctrl keys overriding common VS Code operations such as copy, paste, find, etc. This is some of the stuff I used in Visual Studio Code, that I wanted to bring into Vim. Autocomplete Brackets. This nice little package will auto close those pesky brackets. jiangmiao/auto-pairs. File Icons. This will add icons to stuff like NERDTree. ryanoasis/vim-devicons. Prettier. Wouldn’t you know it, but the official prettier team has

Neo Vim, Almost fully feature-complete VIM integration by utilizing neovim; First-class VSCode insert mode. The plugin unbinds self from the type event in  When I copy and paste a piece of code using Visual Studio Code, after pressing enter to create a new line, the following happens: It seems to keep the indentation created by the new line, adding the previous information from the copied snippet on top of it. I'd rather the code was auto-beautified on paste.

Increase coding productivity with VSCode + Vim, I heard my friend talking about vim at middle of last year. at that time I just last month I just started integration vim plugin call VSCodeVim with VSCode. For copy and paste code in select line. use yy for copy and p for paste. In Visual Studio Code, is it possible to copy selected code to the clipboard with the syntax highlighting? I want to be able to paste into a Word doc or e-mail. Regular Visual Studio does this by default (it puts both text and RTF formats on the clipboard).

Boost Your Coding Fu With Visual Studio Code and Vim, Open Visual Studio Code; Go to Extensions; Type vim in the search box; The first plugin For instance, CTRL-C to copy and CTRL-V to paste. Issue Type: Bug In the past I&#39;ve been able to paste text via ctrl+v when in insert mode. Recently however that shortcut has stopped working. Extension version: 0.11.6 VS Code version: Code 1.23

Comments
  • You can always copy to the clipboard with "+y And past from the clipboard with "+p
  • Do you know why C copy rest the line instead of changing it?
  • Yes! Thank you, this solves one of my problems that the yank y key yanks and the delete key d overwrites the register. I have one more issue though: After yanking I want to replace a 'word' with ci' but the ci' copies word into my clipboard 🤯. Do you know how to disable this functionality?
  • I just answered my own question: { "before": ["c"], "after": ["\"", "_", "c"] }
  • To save you some browsing if you're on OS X: the mapping "before": ["<C-v>"] becomes "before": ["<D-v>"] as Vim considers the command key as "D". Open vim and type :help <D- for more details.
  • Excellent. Thank you!
  • This answer is better than rebinding <C-c> and <C-v> to false because it keeps the shortcut for visual block mode.
  • This may be a correct answer, but it’d be useful to provide additional explanation of your code so developers can understand your reasoning. This is especially useful for new developers who may not be familiar with the syntax. Further, it can help reduce the need for follow-up questions. Would you mind updating your comment with additional details? Take a look at the accepted answer for a good example.