Answer the question
In order to leave comments, you need to log in
How to call my plugin written in Sublime Text 2?
Good day.
I want to write my plugin for Sublime Text 2, but I don't understand how to run it.
I read this article on Habré habrahabr.ru/post/136529 , as well as this (first part) code.tutsplus.com/tutorials/how-to-create-a-sublim... .
By Habr created a new plugin, set hotkeys, left only "Hello World" from the code, saved it.
I try to call it and .... nothing happens!
Maybe I'm doing something wrong? Or am I looking in the wrong place?
Please tell me how, from start to finish, run your plugin on Sublime Text 2 and see its results?
If there is somewhere to read - I will also look with gratitude.
Answer the question
In order to leave comments, you need to log in
Alexander, thanks for the hint, but it didn't quite help :)
But I still understood what my problem was!
It's all about how to name the class and how to call it later via hotkeys!
I could not understand in any way that if I call a class
class SqlBeautifierCommand(sublime_plugin.TextCommand):
[
{ "keys": ["ctrl+m","ctrl+b"], "command": "sql_beautifier" }
]
import sublime, sublime_plugin
class SqlBeautifierCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, 0, "Hello, World!")
[
{ "keys": ["ctrl+m","ctrl+b"], "command": "sql_beautifier" }
]
In the Packages folder, put your *.py file (in a subfolder with the name of your plugin, although you can just put it in the User folder for testing) with the ExampleCommand from the link you provided.
Then in the console (ctrl+`):
import sublime
sublime.active_window().active_view().run_command('example')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question