Sublime Forum

Add keystroke for a menu item/command

#1

This might be a stupid question, but how do I find the internal name for a given command (in a menu) so I can add a key command to my config?

I have one such, but jps told me the command name:

{ "keys": "shift+alt+command+p"], "command": "scope_to_clipboard" }

I’d like to add a command from the Tag plugin.

0 Likes

#2

I think what you need to do is look in the Tag plugin source file and look at the class name.

Sublime Text commands are from the class name of certain classes. They are always in the form WhateverNameCommand. Notice they always end in command. So then you just replace the camel case with underscores and lower case and remove command.

whatever_name
0 Likes

#3

Thank you. Found the command.

  { "keys": "shift+ctrl+r"], "command": "tag_remove_picked_in_selection"  }

How can one be sure a keystroke is not infringing on an existing one?

0 Likes

#4

This is much more difficult. You basically have to search the keymap files of ST2.

I personally, on plugins that I release, try to bind all of my commands to a sequence. I use “ctrl+shift+b”. So everything is “ctrl+shift+b”, “ctrl+shift+something else”]. That way I am only taking one shortcut away and just building combinations off of that.

ST2 uses so many shortcuts that it is becoming increasingly more difficult to find shortcuts. Taking into account all of the plugins that you may install that eat up more shortcuts, it is hard to say which are free.

That is why I also have started to shy away from releasing plugins with shortcuts defined. Instead I create commands in the command palette and let the user create a shortcut if they really want one.

If you are writing a command or plugin for personal use, then you can overwrite shortcuts that you don’t use, but if you plan on releasing it, you have to be very more careful.

0 Likes

#5

Yes, it would be nice, in the future perhaps, if the app could do a “dump” of all key configs and their commands, to a text file/window. So users can refer to it.

0 Likes

#6

In your console, type: sublime.log_commands(True)

1 Like