13

Is there a spacemacs command that both closes the window and kills the buffer? In other words, the equivalent of Vim's :q?

sid-kap
  • 544
  • 1
  • 6
  • 13
  • There is `SPC q Q` for (kill-emacs) - which I guess is the equivalent of :q? If you want an explicit kill buffer kill window command, why don't you write it and add to your `spacemacs-user-config`? – Daniel Nov 26 '16 at 08:20
  • 1
    @dangom In Vim `:q` closes the current window only, it only exits Vim if you are down to your last window. – Omar Aug 14 '18 at 19:09

4 Answers4

18

spacemacs binding for kill-buffer-and-window:

Cx,4,0

sjas
  • 301
  • 3
  • 10
9

Spacemacs has recently added two shortcuts for kill-buffer-and-window: SPC b x and SPC w x.

sid-kap
  • 544
  • 1
  • 6
  • 13
  • 1
    For others that like me are wondering about this, this is not only in Spacemacs. It is added to Emacs itself with vanilla Emacs default binding of `C-x 4 0`. It can be found in `window.el`. – Mehrad Mahmoudian Jan 21 '23 at 11:15
8

Use kill-buffer-and-window to close a buffer and its window. But this will keep emacs running. If you also want to kill emacs (the equivalent of :q) then try evil-quit-all if you're using evil, and save-buffers-kill-terminal for standard emacs quit.

mclear
  • 1,525
  • 9
  • 17
0

In addition to the above answers, in particular the one by sid-kap; for people not on the development branch, i.e. people using the current stable release, the command kill-buffer-and-window is bound to SPC u SPC w d as described (currently) in the key bindings section of the documentation.

dalanicolai
  • 6,108
  • 7
  • 23