0

Update 17 March, 2023: I've used Vim much more now and I have realized the utility in the delete-to-clipboard behavior. If I have this issue, I'll just use Win+V to go back a couple entries in my clipboard.

The default behavior of d and x is to add the deleted text to the buffer/clipboard (so vim p for paste or the ctrl+v for the windows clipboard). It's very common for me to highlight some text to copy, copy it, then go to another point of text to delete, use dd or V to highlight, then d to delete, and then when I go to paste... bam, there is the text that I just deleted instead of what I intended to copy.

VSCode Vim Settings not working for remaps with " VIM: Is there a way to make vim not copy whenever you delete text

What I have in settings.json:

  "vim.normalModeKeyBindings": [
      //in normal mode, change the d keybing to no longer add deleted text to clipboard
      {
          "before": [ "d" ],
          "after": [ "\"", "_", "d"]
      },
      {
          "before": [ "D" ],
          "after": [ "\"", "D" ]
      },
      {
          "before": [ "d", "d" ],
          "after": [ "\"", "_", "d", "d"]
      }
  ],

This breaks Vim for me. When I rebind it with the above code, it's stuck in d mode until I completely restart vscode. When I do the same keybinds normally, without the rebind, it works perfectly fine. I get to delete text without it also copying. I'm certain that it's the first keybind messing things up, and not the dd keybind because this happens even when I comment out the dd rebind.

Also if there's a way to do this instead of altering the keybinds, but to change what the keybind does with a commands: line, that would be helpful too.

I'd be willing to give any more relevant info, or even put in the work of making a proper github issue, but I don't understand how Vim or Vscode Vim works enough to be confident that this isn't intentional behavior or if it's just me being stupid.

Edit: VSCode Vim Settings not working for remaps with "

This answer says to add the "<leader"> tag to the rebind.

"vim.visualModeKeyBindingsNonRecursive": [
    {
      "before": ["<leader>", "d"],
      "after": ["\"", "_", "d"]
    },

This fixes the getting stuck in d mode issue, but it doesn't help with the automatic yanking.

Nate
  • 56
  • 7

0 Answers0