问题
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.
回答1:
Multiple actions is not supported natively (Feature-request: Macro like keybindings #871).
Edit:
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": "multiCommand.down3Lines"
}
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
回答2:
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
来源:https://stackoverflow.com/questions/37009184/multiple-actions-on-one-keyboard-shortcut-in-vscode