Sublime Forum

Sublimetext window command for scope?


For text command I can use

def is_enabled(self):
        return self.view.match_selector(0, "source.python")

to enable my plugin for Python sources only. I need to ask for user input using the window command. This command does not have a view, though. How can I make a window command run for a specific scope only?



if there is no view, what is the scope for?

1 Like


this is my first plugin. I want to create a new file in a certain way using key binding. It should only work on Markdown files (“text.html.markdown”). But the user decides part of the filename.

Would it be enough using the scope on the key binding to trigger the command?



Presuming that your command does something that requires the current file to be of a given type, you can use self.window.active_view() to obtain the currently focused view in the window.

You can also do it in a context in your key binding as well. Or both, so that whether you look at the binding or the code, it’s clear that it’s meant for a specific thing.

Otherwise, I would do it in the command itself so that if the user decides to make their own binding it’s more foolproof.

1 Like