18

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

bombadil
  • 547
  • 4
  • 13

2 Answers2

16

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.

bombadil
  • 547
  • 4
  • 13
ThomasH
  • 326
  • 2
  • 4
  • 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 '19 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.)

  • 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 03 '16 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. – Nathanael Farley Feb 03 '16 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 03 '16 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? – Nathanael Farley Feb 03 '16 at 12:04
  • `SPC b M` is what I was looking for. Thank you – bombadil Feb 03 '16 at 13:35
  • 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 '17 at 20:17
  • It's entirely possible; spacemacs doesn't worry too much about backward compatibility (in my experience) when it comes to changing keyboard shortcuts to make better sense. – Nathanael Farley Dec 08 '18 at 07:25