Sublime text 3 plugin development for custom autocomplete like emmet?
<p>I would like to create my custom plugin like emmet for auto completion and tag expansion for html tags like <code>h2&gt;span</code> .myclass should result in  <code>&lt;div class="myclass"&gt;&lt;/div&gt;</code>.</p>

<p>I started with but didn't find any documentation for tracking the user type event and how to define scope for plugin to be only applied for html files.</p>

<p>When i tried to use print statement inside my class it throws syntax error</p>

<pre><code>def run(self, edit):
  print "i am in run"
  self.view.insert(edit, 0, "Hello, World!")
</code></pre>

<p>How can i debug my plugin code without print statement or is there any alternative for sublime plugin ?</p>

<p>Typically, one doesn't program a plugin to track what the user types in Sublime Text, but instead binds a command to a keybinding. Then, when the user presses that certain key, under certain conditions, defined in the context of the keybinding, the command executes and looks at the text near the selection caret.</p>

<p>Sublime Text plugins are developed in Python 3, where <code>print</code> is not a statement, but a function. Therefore, you need to use <code>print('I am in "run"')</code> to output debug messages to the ST console.</p>

<p>For example, if this was your plugin code:</p>

<pre><code>import sublime
import sublime_plugin


class ThisIsAnExampleCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        print('I am in the "run" method of "ThisIsAnExampleCommand"')
        self.view.insert(edit, 0, "Hello, World!")
</code></pre>

<p>then you might define a keybinding like:</p>

<pre><code>{ "keys": ["tab"], "command": "this_is_an_example",
    "context":
    [
        { "key": "selector", "operator": "equal", "operand": "text.html", "match_all": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
    ]
},
</code></pre>

<p>which would operate when the user presses <kbd>Tab</kbd>, but only if all selections are empty, and the syntax of the current file being edited is HTML.</p>

<p>Your plugin could look at <code>self.view.sel()</code> to get the selection/caret position(s).</p>

python sublimetext3