Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This function makes emacs move the current buffer to another window. It also closes the current tab and sets focus on the new buffer
;; move buffer to other window
;; after c-x 3 to split screen this lets you move buffers between sides.
;; altered code from:
;; http://stackoverflow.com/questions/1774832/how-to-swap-the-buffers-in-2-windows-emacs
(defun swap-buffer-window ()
"Put the buffer from the selected window in next window, and vice versa"
(interactive)
(let* ((this (selected-window))
(other (next-window))
(this-buffer (window-buffer this)))
(set-window-buffer other this-buffer)
(tabbar-close-tab) ;;close current tab
(other-window 1) ;;swap cursor to new buffer
)
)
(global-set-key (kbd "C-x /") 'swap-buffer-window)
@danmayer

This comment has been minimized.

Copy link
Owner Author

commented Jun 5, 2011

If you don't use tabs just comment out the tabbar-close-tab function call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.