Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a key binding shortcut to run a custom package / plugin in sublime text

I have Markdown preview package installed in my sublime text and I want to create a shortcut / key binding for it, let's say: ctrl + shift + p

like image 305
Danillo Corvalan Avatar asked Apr 15 '14 12:04

Danillo Corvalan


People also ask

How do I create a shortcut in Sublime Text?

Select the Key Bindings - User item under Sublime's Preferences, then add the following example line: {"keys": ["ctrl+shift+c"], "command": "insert_snippet", "args": {"contents": "hello!"}} This will add a CTRL + SHIFT + C shortcut to insert the hello! snippet.

How add key bindings sublime?

Users can customize their key bindings by creating a file named Default. sublime-keymap in their Packages/User/ directory. For example, the following will create a key binding to show unsaved changes, if any exist, via Ctrl+Shift+`.

What is the shortcut key to run a program in sublime?

The shortcut key for this purpose is Ctrl+Shift+P for Windows and Cmd+Shift+P for Mac.


1 Answers

In the ST console, enter sublime.log_commands(True) to see what command is being executed form the command palette. Alternatively you can look in the Default.sublime-menu file for the appropriate caption/command pair. After you've done that, you can create a custom key binding. To do this, open your user key binding file by going to Preferences -> Key Binding - User. Enter something like the following.

[
    {"keys": ["ctrl+shift+p"], "command": "<preview_command_here>"}
]

The settings file is just a list, so if you already have an entry, you do not need the square brackets.

like image 180
skuroda Avatar answered Nov 02 '22 19:11

skuroda