Hi all,
I want to create a new “template” so when I create some documents I preload some content. I have read this is better done with a snippet.
The snippet works via the TAB key. However, I cannot get it activated from my plugin to preload content in the new file. The code gets executed but the “run_command” does nothing. How can I make this work?
- C:\Users…\AppData\Roaming\Sublime Text 3\Packages\MyPlugin\templ.sublime-snippet:
<snippet>
<content><![CDATA[
Hello, ${1:this} is a ${2:snippet}.
]]></content>
<tabTrigger>hello</tabTrigger>
<description> demo description </description>
</snippet>
- C:\Users…\AppData\Roaming\Sublime Text 3\Packages\MyPlugin\myplugin.py
def on_done(...):
...
open(path, 'a').close()
new_view = self.window.open_file(path)
new_view.run_command("insert_snippet", {"name" : "Packages/MyPlugin/templ.sublime-snippet"})