Multiple actions on one keyboard shortcut in vscod

2019-01-18 19:14发布

问题:

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 in advance.

回答1:

Multiple actions is not supported natively. But for now you can use extention macros.

settings.json (ctrl+,) >>

"macros": {
    "cursorUp3x": [
        "cursorUp",
        "cursorUp",
        "cursorUp"
    ]
},

keybindings.json (ctrl+k, ctrl+s) keybindings.json link click >>

{
    "key": "ctrl+w",
    "command": "macros.cursorUp3x"
}

Feature-request: Macro like keybindings #871



回答2:

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