18

Is there any keybinding or function to move an open buffer to a different window or a different frame in spacemacs?

2 Answers 2

16
+50

It seems key bindings have been changed in Spacemacs since @Nathanael's answer.

To move a buffer to a diffferent window, you can use SPC b [n] (buffer-to-window-[n]), where n is the number of the window to move to.

If you want to move the window , rather than the buffer (which makes sense in the light of the comments given above):

SPC w [H|J|K|L]

to move the window left|down|up|right, respectively.

1
  • Thanks for the answer! The final sentence is the actual answer to the question (and what I came here looking for), and I very nearly missed it. Might be worth moving it to the top or calling it out better. :)
    – Ipsquiggle
    Jan 21, 2019 at 18:37
4

In spacemacs (vim mode) you can press SPC b m <your-direction> to move a buffer. <your-direction> can be:

  • h left
  • j down
  • k up
  • l right

In emacs mode, it should be M-m b m <your-direction>

If you want to switch to the 'other' frame, you can use SPC b M (or M-m b M).

(In general, Emacs places no restriction on the number of windows/frames a buffer is displayed in, so you can simply switch to the buffer in however many windows/frames you want.)

7
  • and is it possible to move the buffer to a different frame? (ideal would be something comparable to ace-window to select the target window and frame)
    – bombadil
    Feb 3, 2016 at 11:56
  • 1
    You can just switch to the buffer when you are in the other frame, not sure if there's a native spacemacs way to do this though. Feb 3, 2016 at 11:58
  • 1
    Perhaps to clarify, what I am looking for: I have a buffer open in one window want to open it in a different window and frame while closing it in the current one, so that I have the buffer open only in the target window and frame after the move
    – bombadil
    Feb 3, 2016 at 12:00
  • 1
    Perhaps you need something like SPC b M which puts the current buffer in the 'other' frame, then C-x 5 1 to remove all other frames? Feb 3, 2016 at 12:04
  • 2
    I'm not sure if this is still valid — could these commands have changed because when I try to use SPC b m (or look at commands available in buffer mode) it gives the option to kill buffers (specifically spacemacs/kill-other-buffers), and does not offer to move the current buffer. SPC b M seems to be unmapped to any specific command and is remapped to SPC b m which is as before spacemacs/kill-other-buffers. There is a move buffer to window command but it doesn't seem to be mapped to anything in particular. I don't see anything about frames.
    – mpacer
    Apr 17, 2017 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.