我使用 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 命令行
(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')
没有输出。如何从 sublime console
运行 Window
类型的插件?
最佳答案
应用程序命令
:sublime.run_command('application_command_name')
。检查 API reference 中sublime
模块的run_command
函数.WindowCommand
:window.run_command('window_command_name')
。检查sublime.Window
的run_command
方法.TextCommand
:view.run_command('text_command_name')
。检查sublime.View
的run_command
方法.
关于python - 如何从 `sublime console` 运行 WindowCommand 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19677478/