Visual Studio代码。如何在一个热键上添加多个命令?
Visual Studio Code. How can I add several command on one hotkey?
我想在 1 个热键上执行 2 个命令 "F4"
- workbench.action.toggleSidebarVisibility
- workbench.action.toggleActivityBarVisibility
我正在尝试使用此代码,但它不起作用。
{
"key": "F4",
"command": "workbench.action.toggleSidebarVisibility && workbench.action.toggleActivityBarVisibility"
}
不可能,至少在今天的普通安装中是不可能的。
但是你可以在这里试试这个扩展,它从多个命令创建宏,然后可以绑定到快捷方式:https://marketplace.visualstudio.com/items?itemName=geddski.macros
Another way 无需扩展即可实现此目的:
运行 "Tasks: Open User Tasks" 创建或打开用户级任务文件的命令。
将命令定义为单独的任务,如下所示:
{
"version": "2.0.0",
"tasks": [
{
"label": "my-f4-1",
"command": "${command:workbench.action.toggleSidebarVisibility}"
},
{
"label": "my-f4-2",
"command": "${command:workbench.action.toggleActivityBarVisibility}"
},
{
"label": "my-f4",
"dependsOrder": "sequence",
"dependsOn": [
"my-f4-1",
"my-f4-2"
],
"problemMatcher": []
}
]
}
- 在你的 keybindings.json:
{
"key": "f4",
"command": "my-f4"
}
我想在 1 个热键上执行 2 个命令 "F4"
- workbench.action.toggleSidebarVisibility
- workbench.action.toggleActivityBarVisibility
我正在尝试使用此代码,但它不起作用。
{
"key": "F4",
"command": "workbench.action.toggleSidebarVisibility && workbench.action.toggleActivityBarVisibility"
}
不可能,至少在今天的普通安装中是不可能的。
但是你可以在这里试试这个扩展,它从多个命令创建宏,然后可以绑定到快捷方式:https://marketplace.visualstudio.com/items?itemName=geddski.macros
Another way 无需扩展即可实现此目的:
运行 "Tasks: Open User Tasks" 创建或打开用户级任务文件的命令。
将命令定义为单独的任务,如下所示:
{
"version": "2.0.0",
"tasks": [
{
"label": "my-f4-1",
"command": "${command:workbench.action.toggleSidebarVisibility}"
},
{
"label": "my-f4-2",
"command": "${command:workbench.action.toggleActivityBarVisibility}"
},
{
"label": "my-f4",
"dependsOrder": "sequence",
"dependsOn": [
"my-f4-1",
"my-f4-2"
],
"problemMatcher": []
}
]
}
- 在你的 keybindings.json:
{
"key": "f4",
"command": "my-f4"
}