The Computer Oracle

How can I set key bindings for menu items in Sublime Text 2?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Meadow

--

Chapters
00:00 How Can I Set Key Bindings For Menu Items In Sublime Text 2?
00:15 Accepted Answer Score 13
01:14 Thank you

--

Full question
https://superuser.com/questions/544486/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#sublimetext2

#avk47



ACCEPTED ANSWER

Score 13


First, we need to determine the name of the command performed by the menu item:

Select the Packages… menu item (on Mac OS X it's in the application menu, submenu Preferences).

Navigate into the folder Default, and look for Main.sublime-menu. Open this file, and look for an entry corresponding to the label you're looking for. In this case:

{ "command": "refresh_folder_list", "caption": "Refresh Folders", "mnemonic": "e" },

The command name we're looking for is refresh_folder_list.


Now, select the Key Bindings — User menu item. A document will open.

Add the following as an additional entry to the top level array:

{
    "keys": ["ctrl+shift+option+r"], "command": "refresh_folder_list"
}

The file should look like this after editing:

[  
    // possibly other entries in this array, each of them comma separated
    {
        "keys": ["ctrl+shift+option+r"], "command": "refresh_folder_list"
    }
]  

Save and close to assign the keyboard shortcut Ctrl-Shift-Alt-R to Refresh Folders. You can of course specify any key combination you want.