Skip to content

Instantly share code, notes, and snippets.

@pabloasanchez
Last active December 21, 2020 23:20
Show Gist options
  • Save pabloasanchez/f6eb5755b55ed5f4fbe4b43b1805c0ac to your computer and use it in GitHub Desktop.
Save pabloasanchez/f6eb5755b55ed5f4fbe4b43b1805c0ac to your computer and use it in GitHub Desktop.
Sublime Text 3 Plugin: Close all saved tabs
# Place inside Data\Packages\User
# Run: view.run_command("close_saved")
import sublime
import sublime_plugin
class CloseSavedCommand(sublime_plugin.TextCommand):
def run(self, edit):
activeWindow = sublime.active_window()
views = sublime.Window.views(activeWindow)
for each in views:
if each.is_dirty() == False:
print("Dirty: " + str(each.is_dirty()))
print("Closing " + each.file_name())
each.close()
[
{ "caption": "-" },
{ "command": "close_saved", "caption": "Close Saved Files" }
]
@pabloasanchez
Copy link
Author

Thank you for this handy script. I had to fix a minor bug in the code to make it work.

You're welcome, friend. I'm glad you found it useful. Also thank you for the bug fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment