Also new in this beta is the onQueryContext API, for plugins to expose key binding contexts. For example:
- Code: Select all
class NumberContext(sublimeplugin.Plugin):
def onQueryContext(self, view, key, value):
if key == "isNumber":
isNumber = True
for s in view.sel():
char = view.substr(s.begin())
if char < '0' or char > '9':
isNumber = False
return isNumber == (value == "true")
This plugin defines a new key binding context, "isNumber", that allows key bindings that only trigger if the cursor in next to a number. The corresponding key binding would look like:
- Code: Select all
<binding key="ctrl+t" command="whatever">
<context name="isNumber" value="true"/>
</binding>
EDIT: Also, memory usage is substantially improved with many files are open. Startup speed is better due to better IO scheduling, and the CPU time required for startup has also been reduced.