allow scratch buffer switching

This commit is contained in:
Stefan Schwarz 2019-08-05 11:59:13 +02:00
parent d711fc89c3
commit 323a93b081

13
init.el
View file

@ -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)