Jake
Jake

Reputation: 422

vim & vscode: remapping redo to "U"

I am trying to remap the redo command to "U" do that "u" will undo and "U" will redo. I am using vim with vscode and I am trying to change the bindings with this but it is not working.

    "vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": ["U"],
            "after": [],
            "commands": [
                {
                    "command": "redo",
                    "args": []
                }
            ]
         },
      ],

Upvotes: 1

Views: 1408

Answers (2)

Drakinite
Drakinite

Reputation: 362

The Vim extension appears to handle undo/redo on its own, separately from VS Code. So if you ever do ctrl + z / ctrl + shift + z (for example, simply due to muscle memory), and mix it in with vim's undo/redo, then things will get very messy, very quickly.

I believe the fact that vim handles its own undo/redo is why sending the "redo" command in your first attempt did not work.

This worked for me, personally:

    "vim.normalModeKeyBindings": [
        { "before": ["u"], "commands": ["undo"] },
        { "before": ["U"], "commands": ["redo"] },
    ],

This forces the vim extension to use the same undo/redo system as the rest of VS Code, preventing the mess that I eluded to earlier.

Upvotes: 0

Jake
Jake

Reputation: 422

    "vim.normalModeKeyBindings": [
        ...
        {
            "before": ["U"],
            "after": ["C-r"]
         },
      ],

Upvotes: 3

Related Questions