Search code examples
vimvisual-studio-codevim-plugin

Is it possible to change default commands in VScode Vim?


I would like to change dd (delete and put into register) to "_dd (delete and put into black hole register). I tried below remap, to no avail.

  {
      "before": [
        "d",
        "d"
      ],
      "after": [
        "\"",
        "_",
        "d",
        "d",
      ]
    }


However, when I try below remap with leader, it works.

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



Is it even possible to change default behaviour of dd?

Thanks.


Solution

  • You can use this:

    "vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": ["d"],
            "after": [ "\"", "_", "d" ]
        }
    ]
    

    but the catch is that it changes the 'd', instead of changing 'dd' i.e. 'dd' will work as you want but it will also change every keymapping related to 'd'.

    'dw' will also delete to 'black hole' register, so will 'dd'

    To know more check out this https://github.com/VSCodeVim/Vim/pull/3081

    Remapping 'dd' doesn't change like it does in vim, it is better to use the 'leader d' to get what you want if you don't want to change the default functionality of 'd'.

    In short vim can do what you want but vim plugin in vscode doesn't support it now.