我使用3个命令为sublime text 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")
为什么我只能从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
但无法调用window
命令:
>>> view.run_command('simple_window_plugin')
没有输出。如何从Window
运行sublime console
类型插件?
答案 0 :(得分:10)
ApplicationCommand
:sublime.run_command('application_command_name')
。在API reference。{/ li>中查看run_command
模块的sublime
功能
WindowCommand
:window.run_command('window_command_name')
。查看sublime.Window
的run_command
方法。TextCommand
:view.run_command('text_command_name')
。查看sublime.View
的run_command
方法。