Home Download Buy Blog Forum Support

How to create key binding to python script?

How to create key binding to python script?

Postby cviebrock on Thu Feb 23, 2012 5:45 pm

I'd like to bind SUPER+SHIFT+7 to the Packages/HTML/encode_html_entities.py function ... instead of what I do now which is pull up the command palette and find "HTML: Encode Special Characters".

How would I do this? I can't find info on binding to a Python script.

Thanks in advance!
- Colin
cviebrock
 
Posts: 14
Joined: Wed Nov 02, 2011 5:47 pm

Re: How to create key binding to python script?

Postby fizzicist on Thu Feb 23, 2012 10:29 pm

The "HTML: Encode Special Characters" entry in the Command Palette corresponds to the "encode_html_entities" command. If you put the following in your "Default (OSX). sublime-keymap" file (or other OS-appropriate keymap file), it will bind the command to the super+shift+7 keystroke:

Code: Select all
{ "keys": ["super+shift+7"], "command": "encode_html_entities" }


Edited to add: The Python script you mentioned defined the encode_html_entities command. The command is loaded by Sublime, so you don't have to figure out how to run the script. Sublime takes care of calling the script, whether you execute it via the Command Palette, a keystroke in a keymap, etc. Magic!

h.b.
fizzicist
 
Posts: 4
Joined: Thu Aug 11, 2011 3:53 am


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 27 guests