[英]Multiple actions on one keyboard shortcut in vscode
Is it possible to have multiple actions assigned to one keyboard shortcut in visual studio code?是否可以将多个操作分配给 Visual Studio 代码中的一个键盘快捷键?
For example: Move cursor up x 3 set to "ctrl + w"例如:将 cursor 向上移动 x 3 设置为“ctrl + w”
Thanks in advance.提前致谢。
It's possible with extensions like Commands可以使用像Commands这样的扩展
settings.json
"commands.commands": {
"down3": {
"sequence": [
"cursorDown",
"cursorDown",
"cursorDown",
],
},
},
keybindings.json
{
"key": "ctrl+w",
"command": "down3",
},
Or with just keybindings.json
或者只使用keybindings.json
{
"key": "ctrl+w",
"command": "commands.run",
"args": [
"cursorDown",
"cursorDown",
"cursorDown"
]
},
Feature request to support Macro like keybindings #871 .支持像键绑定这样的宏的功能请求#871 。
Although, for this particular example it's better to use the built-in
command (to avoid any jumpiness):虽然,对于这个特定的例子,最好使用built-in
命令(以避免任何跳跃):
{
"key": "ctrl+w",
"command": "cursorMove",
"args": {
"to": "down",
"by": "line",
"value": 3
}
}
https://code.visualstudio.com/api/references/commands https://code.visualstudio.com/api/references/commands
For anyone else looking for an answer, learn to make your own VS code extensions.对于正在寻找答案的其他人,请学习制作自己的 VS 代码扩展。 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 vs 代码站点有很好的资源: https : //code.visualstudio.com/docs/extensions/overview
I use the macros extension ( https://marketplace.visualstudio.com/items?itemName=geddski.macros ):我使用宏扩展( https://marketplace.visualstudio.com/items?itemName=geddski.macros ):
in settings.json:在 settings.json 中:
"macros": {
"showGit": ["workbench.view.scm", "git-graph.view"]
}
then in keybindings.json:然后在 keybindings.json 中:
{
"key": "ctrl+shift+g",
"command": "showGit"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.