Skip to content

Instantly share code, notes, and snippets.

@boredstiff
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save boredstiff/8632c3f0d13eb4b2c5fa to your computer and use it in GitHub Desktop.

Select an option

Save boredstiff/8632c3f0d13eb4b2c5fa to your computer and use it in GitHub Desktop.
Key-based Commands for Sublime Text
"""
Keybindings: Preferences > Key Bindings - User
(brackets included)
============
[
{"keys": ["ctrl+t"], "command": "toggle_side_bar"},
{"keys": ["ctrl+v"], "command": "paste_and_indent"},
{"keys": ["ctrl+shift+v"], "command": "paste"},
{ "keys": ["ctrl+shift+m"], "command": "open_msdn" },
{ "keys": ["ctrl+shift+m"], "command": "open_msdn" },
{ "keys": ["ctrl+shift+p"], "command": "alex_to_do_python"},
{ "keys": ["ctrl+shift+o"], "command": "alex_to_do_cpp"},
{ "keys": ["ctrl+shift+n"], "command": "alex_notes"},
{ "keys": ["ctrl+shift+0"], "command": "alex_print_time"},
{ "keys": ["ctrl+shift+9"], "command": "alex_msdn_notes"},
// From My Modo Plugin Builder plugin for Sublime
// http://alexwidener.github.io/ModoPluginBuilder/
{ "keys": ["ctrl+."], "command": "search_tdsdk_docs"},
{ "keys": ["ctrl+,"], "command": "search_python_docs"}
]
============
Preferences > Browse Packages > User
Save this file there.
"""
__author__ = "Alex Widener"
__date__ = "June 21, 2015"
__status__ = "Production"
__version__ = "1.0"
__email__ = "alexwidener#google"
import sublime_plugin
import webbrowser
import time
def open_browser(value):
url = 'https://social.msdn.microsoft.com/Search/en-US/windows/desktop?query=%s&Refinement=181&emptyWatermark=true' % value
webbrowser.open(url)
class OpenMsdnCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.show_input_panel("MSDN: ", '', open_browser, None, None)
pass
class AlexToDoPythonCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, self.view.sel()[0].begin(), "# TODO(Alex): ")
class AlexToDoCppCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, self.view.sel()[0].begin(), "// TODO(Alex): ")
class AlexNotesCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, self.view.sel()[0].begin(), "// Notes(Alex): ")
class AlexPrintTimeCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, self.view.sel()[0].begin(),
"// %s : " % (time.strftime("%I:%M:%S %p")))
class AlexMsdnNotesCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, self.view.sel()[0].begin(),
"// Look up on MSDN: ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment