Skip to content

Commit 50287fe

Browse files
committed
Improve new snippet code slightly
1 parent b038f13 commit 50287fe

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

snippet_dev.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
% PLUGIN_NAME)
2222

2323

24-
TPL = """<snippet>
24+
SNIPPET_TEMPLATE = """<snippet>
2525
<content><![CDATA[$1]]></content>
2626
<tabTrigger>${2:tab_trigger}</tabTrigger>
2727
<scope>${3:source.name}</scope>
28-
</snippet>"""
28+
<!-- <description></description> -->
29+
</snippet>""".replace(" ", "\t") # always use tabs in snippets
2930

3031

3132
class NewRawSnippetCommand(sublime_plugin.WindowCommand):
@@ -43,12 +44,13 @@ def is_enabled(self):
4344
def run(self, edit):
4445
content = get_text(self.view)
4546
clear(self.view)
46-
self.view.run_command('insert_snippet', {'contents': TPL})
47+
self.view.run_command('insert_snippet', {'contents': SNIPPET_TEMPLATE})
4748
self.view.set_syntax_file(SNIPPETS_SYNTAX)
4849
# Insert existing contents into CDATA section. We rely on the fact
4950
# that Sublime will place the first selection in the first field of
5051
# the newly inserted snippet.
5152
self.view.insert(edit, self.view.sel()[0].begin(), content)
53+
self.view.run_command("next_field")
5254

5355

5456
class NewRawSnippetFromSnippetCommand(sublime_plugin.TextCommand):

0 commit comments

Comments
 (0)