Sublime Forum

Closing literally around 1300 files - add the function to CLOSE ALL Files without saving :)

#1

While sorting files, I had to make changes to more than 1k files. there is an option to SAVE ALL files but what about to CLOSE ALL files without saving? I had to click more than 100 times to the pop-up window that ask if I want to save the changes made to the file

for the 1k files I had to cancel the Close all files, then save them, then went to my directory and delete them

1 Like

#2

you can mark them all as scratch using a one line Python script, but you may want to upvote this:


0 Likes

#3

Save this in your User directory and create a keybinding. Be careful when choosing how you call this, you don’t want to accidentally delete everything.

{"keys": ["ctrl+shift+q"], "command": "close_without_saving"},
import sublime
import sublime_plugin


class CloseWithoutSaving(sublime_plugin.WindowCommand):
    def run(self):
        window = self.window

        for v in window.views():
            if v.is_dirty():
                v.set_scratch(True)

        window.run_command("close")
1 Like

#4

This really needs to be a built-in option. I’ve accidentally run find’n’replace on a temporary folder, and I’m stuck with 2000 tabs that refuse to close.

It’s silly I need to manually write a plugin to have the editor back to usable state.

0 Likes

#5

You can type the command into the console. You don’t have to write a full plugin; it’s just convenient if you want to do it regularly.

N.B. sublime_lib makes this easier:

from sublime_lib import close_window
close_window(window, force=True)
0 Likes