Toggle between most recent buffers

Here is a handy function to toggle between the two most recent buffers. It has the same effect as C-x b RET but can be bound to a simple key combination. I set it to C-` since it reminds me of the CMD-` used in OS X to switch between windows of the same app.

This code comes from the emacs wiki

;; toggle between most recent buffers                                     ;;
(defun switch-to-previous-buffer ()
  "Switch to most recent buffer. Repeated calls toggle back and forth between the most recent two buffers."
  (switch-to-buffer (other-buffer (current-buffer) 1)))

;; set key binding
(global-set-key (kbd "C-`") 'switch-to-previous-buffer)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s