Multiple actions on one keyboard shortcut in vscode

℡╲_俬逩灬. 提交于 2019-12-28 16:31:39

问题


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 (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": "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




回答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



来源:https://stackoverflow.com/questions/37009184/multiple-actions-on-one-keyboard-shortcut-in-vscode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!