I'd like to bind a shortcut key to Edit > Tag > Wrap Selection with Tag
. How do I figure out the command name so I can put that into the user key bindings?
3 Answers
Hit Ctrl` (backtick) to open the console, then enter
sublime.log_commands(True)
to turn on command logging. Go through the menus and click your target, and
command: insert_snippet {"name": "Packages/XML/long-tag.sublime-snippet"}
comes up. Enter the following into your Preferences -> Key Bindings - User
file:
{ "keys": ["ctrl+alt+shift+w"], "command": "insert_snippet", "args": { "name": "Packages/XML/long-tag.sublime-snippet" } }
(changing the key combo if you wish) and you should be all set. Once you're done, go back to the console and enter
sublime.log_commands(False)
to turn off logging of every single action.
-
1thanks!
sublime.log_commands(True)
has been incredibly useful for me, both as a plugin writer and just for customizing key bindings, etc.– MattDMoSep 18, 2013 at 20:54 -
1Wicked!! Thanks! You win because you explain how I can use
log_commands
to find out any command from the menus. Sep 19, 2013 at 2:56 -
Really need this (sublime.log_commands(True)) for Visual Studio Code. Anyone know if it exists / how to get it working?– MatthewJun 26, 2017 at 1:34
-
Thanks @MattDMo!
sublime.log_commands(True)
work for me to figure out JSON Reindent package command. Jun 17, 2021 at 9:04
Goto Preferences > Key Bindings - Default
then search for alt+shift+w
and you'll find the following, on line 566 for me:
{ "keys": ["alt+shift+w"], "command": "insert_snippet", "args": { "name": "Packages/XML/long-tag.sublime-snippet" } },
You can change the ["alt+shift+w"]
to whatever you'd like. I'd suggest making this a new entry in Preferences > Key Bindings - User
so you don't overwrite the defaults file.
Go to Preferences -> Settings User
and add the following line:
{ "keys": ["ctrl+shift+w"], "command": "insert_snippet", "args": { "name": "Packages/XML/long-tag.sublime-snippet" } }
(change ctrl+shift+w
- to your preferred shortcut)
In general, whenever you want to change a default, go to Preferences -> Settings default
and look for the current shortcut - copy the line to the "User" settings and modify it.