vscode中一个键盘快捷键上的多项操作 [英] Multiple actions on one keyboard shortcut in vscode

查看:282
本文介绍了vscode中一个键盘快捷键上的多项操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

谢谢.

推荐答案

本机不支持多个操作(功能请求:宏像键绑定#871 ).

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

macros在最新版本的vscode中似乎无法正常工作.不过,还有其他扩展名,例如:多命令

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" },
},


尽管如此,对于此特定示例,也可以使用built-in命令(以避免任何跳跃):


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

这篇关于vscode中一个键盘快捷键上的多项操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆