Reputation: 121
I'm trying to use Will Bond's guide to creating a Sublime Text plugin (http://code.tutsplus.com/tutorials/how-to-create-a-sublime-text-2-plugin--net-22685).
Step 1 of the guide says to create a default plugin with the following code:
import sublime, sublime_plugin
class ExampleCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, 0, "Hello, World!")
This plugin gets saved as Prefixr.py in:
Sublime_Text_3_Location/Packages/Prefixr
I then type the following command into the Sublime Text console:
view.run_command('example')
And this should insert "Hello, World!" at the beginning of my currently viewed file.
However, when I enter the command, nothing happens. No "Hello, World!" appears in my file. Restarting Sublime Text does not fix it. Neither does running the command from different files.
Any idea why the command does not work?
Upvotes: 1
Views: 534
Reputation: 253
I know this is way old but another stupid error I ran in to was that when I saved my file i accidently saved it as a py3 file and not a py file, duh!
Upvotes: 0
Reputation: 443
I believe this didn't work for me at first because there were some other plugins "before" this one that were trying to import "sublimePlugin" which my ST3 Win7 instance didn't like. I had to import "sublime_plugin".
Upvotes: 0