Multiple actions on one keyboard shortcut in vscode

后端 未结 2 369
悲哀的现实
悲哀的现实 2020-12-10 10:43

Is it possible to have multiple actions assigned to one keyboard shortcut in visual studio code?

For example: Move cursor up x 3 set to \"ctrl + w\"

Thanks i

相关标签:
2条回答
  • 2020-12-10 11:15

    Multiple actions is not supported natively (Feature-request: Macro like keybindings #871).

    Edit: macros doesn't seem to be working properly in the latest versions of vscode. There are other extensions though, like: multi-command

    "multiCommand.commands": [
        {
            "command": "multiCommand.down3Lines",
            "sequence": [
                "cursorDown",
                "cursorDown",
                "cursorDown"
            ]
        },
    ]
    

    keybindings.json

    {
        "key": "ctrl+w",
        "command": "extension.multiCommand.execute",
        "args": { "command": "multiCommand.down3Lines" },
    },
    

    Although, for this particular example it's possible to use built-in command (to avoid any jumpiness):

    {
        "key": "ctrl+w",
        "command": "cursorMove",
        "args": {
            "to": "down",
            "by": "line",
            "value": 3
        }
    }
    

    https://code.visualstudio.com/api/references/commands

    0 讨论(0)
  • 2020-12-10 11:15

    For anyone else looking for an answer, learn to make your own VS code extensions. It took about an hour and I was able to make all sorts of shortcuts that executed multiple commands. The vs code site has good resources for it: https://code.visualstudio.com/docs/extensions/overview

    0 讨论(0)
提交回复
热议问题