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.
It's possible with extensions like Commands
settings.json
"commands.commands": {
"down3": {
"sequence": [
"cursorDown",
"cursorDown",
"cursorDown",
],
},
},
keybindings.json
{
"key": "ctrl+w",
"command": "down3",
},
Or with just keybindings.json
{
"key": "ctrl+w",
"command": "commands.run",
"args": [
"cursorDown",
"cursorDown",
"cursorDown"
]
},
Feature request to support Macro like keybindings #871 .
Although, for this particular example it's better to use the built-in
command (to avoid any jumpiness):
{
"key": "ctrl+w",
"command": "cursorMove",
"args": {
"to": "down",
"by": "line",
"value": 3
}
}
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
I use the macros extension ( https://marketplace.visualstudio.com/items?itemName=geddski.macros ):
in settings.json:
"macros": {
"showGit": ["workbench.view.scm", "git-graph.view"]
}
then in keybindings.json:
{
"key": "ctrl+shift+g",
"command": "showGit"
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.