Sublime Forum

Wanring before quit

#1

Hi, Sublime have option like Google Chrome while using Command + Q?
I usually using Command + W to close current tab, sometime i hit wrong to Command + Q and Sublime quit :frowning:

0 Likes

#2

I’m not aware of any internal option to make Sublime do this; generally with hot_exit on the application state would be saved and restored and it usually starts pretty fast.

You can add this functionality with a simple plugin and key binding, though. If you’re not sure how to use plugins, see this video.

import sublime
import sublime_plugin


class ConfirmQuitCommand(sublime_plugin.ApplicationCommand):
    def run(self):
        if sublime.yes_no_cancel_dialog("Are you sure you want to Quit?") == sublime.DIALOG_YES:
            sublime.run_command("exit")

Once the plugin is in place, you can add a key binding that overrides the default to run this new command instead of the internal one.

    { "keys": ["super+q"], "command": "confirm_quit" },
3 Likes

#3

Thank you. It worked :slight_smile:

0 Likes