Sublime Forum

Disable save when close file with certain name, on_close eventlistner


So in ST4, if we close an “Untitled” tab without any text, then the save change prompt
will not show up.

However, if that “Untitled” tab has text or the name of the tab is something else, then the previous prompt will show up.

I am trying to create a eventlistner to disable the save prompt when the tab name is “Query Result”.

class closeFile(sublime_plugin.EventListener):
    def on_close(self, view):
        if "Query Result" in

I created something like this, looks it runs when I close the file, but it will not close directly without show the save prompt

I also try the on_pre_close, it still doesn’t work…

Any thought on this? Thank y’all so much !



What you want to do is set the file to be a scratch buffer. Scratch buffers don’t prompt when closing.

1 Like


This is exactly what I need. Thanks for sharing!