6

sublime text 3我用 3 个命令创建了插件:其中 2 个是 type 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

4

1 回答 1

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
于 2013-10-30T09:23:01.937 回答