在Visual Studio代码中是否可以将多个操作分配给一个键盘快捷键?

例如:
将光标向上移动x 3并设置为“ctrl + w”

提前致谢。

最佳答案

本机不支持多个操作(功能请求:Macro like keybindings #871)。



"multiCommand.commands": [
    {
        "command": "multiCommand.down3Lines",
        "sequence": [
            "cursorDown",
            "cursorDown",
            "cursorDown"
        ]
    },
]
keybindings.json
{
    "key": "ctrl+w",
    "command": "extension.multiCommand.execute",
    "args": { "command": "multiCommand.down3Lines" },
},

虽然,对于此特定示例,可以使用built-in命令(以避免出现任何跳跃):

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

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

10-08 16:21