diff --git a/Default (Linux).sublime-keymap b/Default (Linux).sublime-keymap index e30a045..c97ab93 100644 --- a/Default (Linux).sublime-keymap +++ b/Default (Linux).sublime-keymap @@ -3,5 +3,10 @@ "keys": ["ctrl+k", "ctrl+tab"], "command": "show_overlay", "args": {"overlay": "command_palette", "command": "switch_window"} + }, + { + "keys": ["ctrl+k", "ctrl+\\"], + "command": "switch_window", + "args": {"previous_window": true} } ] diff --git a/Default (OSX).sublime-keymap b/Default (OSX).sublime-keymap index e30a045..c97ab93 100644 --- a/Default (OSX).sublime-keymap +++ b/Default (OSX).sublime-keymap @@ -3,5 +3,10 @@ "keys": ["ctrl+k", "ctrl+tab"], "command": "show_overlay", "args": {"overlay": "command_palette", "command": "switch_window"} + }, + { + "keys": ["ctrl+k", "ctrl+\\"], + "command": "switch_window", + "args": {"previous_window": true} } ] diff --git a/Default (Windows).sublime-keymap b/Default (Windows).sublime-keymap index e30a045..c97ab93 100644 --- a/Default (Windows).sublime-keymap +++ b/Default (Windows).sublime-keymap @@ -3,5 +3,10 @@ "keys": ["ctrl+k", "ctrl+tab"], "command": "show_overlay", "args": {"overlay": "command_palette", "command": "switch_window"} + }, + { + "keys": ["ctrl+k", "ctrl+\\"], + "command": "switch_window", + "args": {"previous_window": true} } ] diff --git a/Default.sublime-commands b/Default.sublime-commands index 4114dda..7527601 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -3,6 +3,11 @@ "caption": "Switch: Window", "command": "switch_window" }, + { + "caption": "Switch: To Previous Window", + "command": "switch_window", + "args": { "previous_window": true }, + }, { "caption": "Preferences: Switch Window Key Bindings", "command": "edit_settings", diff --git a/plugin.py b/plugin.py index 951929d..a32a9e3 100644 --- a/plugin.py +++ b/plugin.py @@ -91,11 +91,24 @@ def input_description(self): return "Switch Window" def input(self, args): - if args.get("window_id") is None: + if 'previous_window' not in args and args.get("window_id") is None: return WindowInputHandler() return None - def run(self, window_id=None): + def run(self, previous_window=False, window_id=None): + """ + Execute `switch_window` command + + :param previous_window: + If ``true`` directly switch to previous window. + :param window_id: + The window identifier of the window to switch to. + """ + if previous_window: + if len(_history) >= 2: + _history[1].bring_to_front() + return + for window in sublime.windows(): if window.id() == window_id: window.bring_to_front()