diff --git a/core/core-funcs.el b/core/core-funcs.el index 9f7334f16..00a1049ae 100644 --- a/core/core-funcs.el +++ b/core/core-funcs.el @@ -319,6 +319,16 @@ current window." ;; `other-buffer' honors `buffer-predicate' so no need to filter (other-buffer current-buffer t))))) +(defun spacemacs/alternate-window () + "Switch back and forth between current and last window in the +current frame." + (interactive) + (let (;; switch to first window previously shown in this frame + (prev-window (get-mru-window nil t t))) + ;; Check window was not found successfully + (unless prev-window (user-error "Last window not found.")) + (select-window prev-window))) + (defun spacemacs/comint-clear-buffer () (interactive) (let ((comint-buffer-maximum-size 0)) diff --git a/doc/DOCUMENTATION.org b/doc/DOCUMENTATION.org index a27eacd22..33c2e1658 100644 --- a/doc/DOCUMENTATION.org +++ b/doc/DOCUMENTATION.org @@ -1876,6 +1876,7 @@ Windows manipulation commands (start with ~w~): | Key Binding | Description | |------------------------+-----------------------------------------------------------------------------| +| ~SPC w TAB~ | switch to alternate window in the current frame (switch back and forth) | | ~SPC w =~ | balance split windows | | ~SPC w b~ | force the focus back to the minibuffer (useful with =helm= popups) | | ~SPC w c~ | maximize/minimize a window and center it | diff --git a/layers/+distributions/spacemacs-base/keybindings.el b/layers/+distributions/spacemacs-base/keybindings.el index 696451e25..8fbc5d91e 100644 --- a/layers/+distributions/spacemacs-base/keybindings.el +++ b/layers/+distributions/spacemacs-base/keybindings.el @@ -368,6 +368,7 @@ (golden-ratio))) (spacemacs/set-leader-keys + "w TAB" 'spacemacs/alternate-window "w2" 'spacemacs/layout-double-columns "w3" 'spacemacs/layout-triple-columns "wb" 'spacemacs/switch-to-minibuffer-window