问题
Trying to figure out how to create a key binding for a specific command. I can see the command in the pallete but it has no bindings so I can't see it in the keybindings.json.
Is there any way I can LOG all commands being executed within VSC so that I can perform the command and see the command name in the log?
Edit:
To make it clear:
- I want general method to know how I can find what commands were issued along with their command IDs.
- I already know I find some commands in the
default keybindingsfile and that's NOT a general way to find the command you have run. It doesn't list all command not does it explain what they each are and you can't use it to verify that it is the command you executed.
回答1:
You can create binding using Keyboard Shortcuts as well (Preferences: Open Keyboard Shortcuts command). You can search by command name and and even check its corresponding id:
Second option is that you can enable tracing and see executed commands in output panel (it looks like it doesn't log commands executed from command palette though):
Set log level to
trace. You can either pass --log argument when starting VS Code like:code --log trace(doesn't work for me for some reason) or executeDeveloper: Set Log Level...from command palette:After that, you should see executed commands in output panel for Window process.
回答2:
The "Toggle Line Comment" command's id is editor.action.commentLine.
You can find all the command ids by using the search feature in the Keyboard Shortcuts Editor (on macOS you can open it via Application Menu > Preferences > Keyboard Shortcuts or using the shortcut Cmd+K Cmd+S).
In the keybindings.json you can trigger the autocomplete help (i.e. Ctrl+Space) and search all available commands.
来源:https://stackoverflow.com/questions/44453308/vsc-command-log