Sublime Forum

How to close and don't save all open tabs

#1

I did a find a replace and by accident did my entire project, which opened up 30,000 tabs and made the change. Now I want to discard all the changes, but there is not a “Don’t Save All” button in the confirmation modal.

How do I close and don’t save all open tabs?

See:

0 Likes

#2

Restart your pc :smile:

0 Likes

#3

Run this in the console:

len(v.run_command("revert") for v in window.views())

It will undo all changes in the currently opened views.

0 Likes

#4

Thanks for the reply, but getting an error:

>>> len(v.run_command("revert") for v in window.views()) Traceback (most recent call last): File "<string>", line 1, in <module> TypeError: object of type 'generator' has no len()

I am running version 3083.

0 Likes

#5

Sorry,

len([v.run_command("revert") for v in window.views()])

then.

1 Like

#6

That worked. You sir deserve a beer! Thanks so much.

1 Like

#7

[quote=“FichteFoll”]Sorry,

len([v.run_command("revert") for v in window.views()])

then.[/quote]

Please I must have multiple tabs open and I need to “save and close all of them” at once, but every each of them with a different name: i.e I have 20 tabs open and I´d like to close all of them at once but being numbered from 1 to 20: is this possible? for the moment what I do is: Ctrl+S then save as HTML “1”, then Crtl+W and go to the next tab.

I´ll be very thankful if you can help me out with this!!! but if it aín´t possible thank you nayways!!!

jl

0 Likes

#8

Thanks a lot!

I used it to save all tables:

len([v.run_command("save") for v in window.views()])
0 Likes

#9

Sorry for bringing this back to life, but anyone have a suggestion for doing the same on newly opened files?
The files in question don’t exist yet, so the revert command above doesn’t work, it still shows the save dialog for each and every file.

For context, I mistyped a terminal command: subl $(somefile.pl) instead of subl $(which somefile.pl), so sublime has opened every word output by the perl script as a new document name.

Happy to hear any other suggestions on how to fix this problem too, I really don’t want to hit “Don’t Save” 1000s of times, and sublime will remember and reopen the window I’m sure. I’d rather not nuke my saved windows entirely, but that’s the best option I can think of right now.

I’ve looked through the commands I can find at https://docs.sublimetext.io/reference/commands.html but none seem to fit this scenario (close_window still shows the modal dialogs).

As an aside, would be nice if Sublime had a multi-file save changes dialog for this scenario, I know other editors do.

EDIT: I solved the problem with this package: https://packagecontrol.io/packages/Close%20All%20without%20Confirmation

0 Likes