diff --git a/init.el b/init.el index 766a1ae..3f6f8ee 100644 --- a/init.el +++ b/init.el @@ -174,6 +174,10 @@ "ar" 'ranger "ad" 'dired + ;; Buffers + "b" '(:ignore t :which-key "Buffers") + "bs" 'switch-to-scratch-buffer + ;; Files "ff" 'counsel-find-file "fL" 'counsel-locate @@ -261,6 +265,15 @@ (window-configuration-to-register ?_) (delete-other-windows))))) +(defun switch-to-scratch-buffer (&optional arg) + "Switch to the `*scratch*' buffer, creating it first if needed. +if prefix argument ARG is given, switch to it in an other, possibly new window." + (interactive "P") + (let ((exists (get-buffer "*scratch*"))) + (if arg + (switch-to-buffer-other-window (get-buffer-create "*scratch*")) + (switch-to-buffer (get-buffer-create "*scratch*"))))) + (defun switch-to-last-buffer () "Switch to the last buffer, allowes quick jumping between the last two." (interactive)