Max*_*mov 5 python plugins sublimetext sublimetext2 sublimetext3
我sublime text 3
用3个命令创建了插件:其中2个是类型TextCommand
,其中一个是WindowCommand
import sublime, sublime_plugin
class simple_text_pluginCommand(sublime_plugin.TextCommand):
def run(self, edit):
print("Hello World simple_text_plugin")
class simple_text_plugin2Command(sublime_plugin.TextCommand):
def run(self, edit):
print("Hello World simple_text_plugin2")
class simple_window_pluginCommand(sublime_plugin.WindowCommand):
def run(self):
print("Hello World simple_window_plugin")
Run Code Online (Sandbox Code Playgroud)
为什么我只能从sublime command line
(ctrl +`)调用文本命令:
>>> view.run_command('simple_text_plugin')
Hello World simple_text_plugin
>>> view.run_command('simple_text_plugin2')
Hello World simple_text_plugin2
Run Code Online (Sandbox Code Playgroud)
但不能调用window
命令:
>>> view.run_command('simple_window_plugin')
Run Code Online (Sandbox Code Playgroud)
没有输出.如何运行Window
类型插件sublime console
?
lon*_*hua 11
ApplicationCommand
:sublime.run_command('application_command_name')
.在API参考中检查模块的run_command
功能.sublime
WindowCommand
:window.run_command('window_command_name')
.检查run_command
方法sublime.Window
.TextCommand
:view.run_command('text_command_name')
.检查run_command
方法sublime.View
.