Skip to content

Commit

Permalink
keyboard shortcut to edit snippets quickly
Browse files Browse the repository at this point in the history
  • Loading branch information
2shortplanks committed Oct 20, 2011
1 parent 86e608a commit a0922a2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Default.sublime-keymap
@@ -1,6 +1,10 @@
[
{
"keys": ["tab"],
"command": "super_snippet"
"keys": ["tab"],
"command": "super_snippet"
},
{
"keys": ["ctrl+alt+super+s"],
"command": "show_super_snippet"
}
]
28 changes: 28 additions & 0 deletions ShowSuperSnippetCommand.py
@@ -0,0 +1,28 @@
import sublime, sublime_plugin, os, re

a_to_z = re.compile("^[A-Za-z0-9_-]*$")

class ShowSuperSnippetCommand(sublime_plugin.WindowCommand):

def open_snippet(self, word):
# is this in our settings file? This should be in your User dir
# and look like { "shorttext": "expanded texmplate", ... }
settings = sublime.load_settings("SuperSnippet.sublime-settings")
if settings.has(word):
path = os.path.join(sublime.packages_path(),"User","SuperSnippet.sublime-settings")
self.window.open_file(path,sublime.TRANSIENT)
return

else:
# look for a file that is named after the snippet in the
# User directory. we will only do this if the snippet has an
# ascii A-Za-z short form
if a_to_z.match(word):
path = os.path.join(sublime.packages_path(),"User","%s.sublime-supersnippet" % word)
self.window.open_file(path,sublime.TRANSIENT)
else:
return

def run(self):
self.window.show_input_panel("Show Super Snippet:", "", self.open_snippet, None, None)

2 changes: 1 addition & 1 deletion SuperSnippetCommand.py
@@ -1,6 +1,6 @@
import sublime, sublime_plugin, os, re

a_to_z = re.compile("^[A-Za-z_-]*$")
a_to_z = re.compile("^[A-Za-z0-9_-]*$")

class SuperSnippetCommand(sublime_plugin.TextCommand):

Expand Down

0 comments on commit a0922a2

Please sign in to comment.