Reputation: 110510
Is there a command to kill all buffers in my emacs? instead of having me doing 'Ctrl -k ' one by one until there is no more buffer?
Thank you.
Upvotes: 8
Views: 4198
Reputation: 654
In Doom Emacs, there is also a function doom/kill-all-buffers
which is bound to SPC q F
and SPC b K
by default.
Upvotes: 0
Reputation: 3226
I am using this function to kill all the buffers in emacs
(defun nuke-all-buffers ()
(interactive)
(mapcar 'kill-buffer (buffer-list))
(delete-other-windows))
(global-set-key (kbd "C-x K") 'nuke-all-buffers)
Works fine for me :-)
Upvotes: 12
Reputation: 1261
Highly hack-ish, but does what you want:
(defun my-kill-everything ()
(interactive)
(dolist (cur (buffer-list))
(kill-buffer cur)))
Note that Emacs always needs at least one buffer, so you'll end up with an empty scratch buffer again. (Yes, this command also kills stuff like the minibuffer, but it will be restored. As I've written: highly hack-ish.)
Upvotes: 1
Reputation: 73246
M-x ibuffer
RET
tDy
I highly recommend binding C-xC-b to ibuffer
as a replacement for the default binding:
(global-set-key (kbd "C-x C-b") 'ibuffer)
(I've also bound my <menu> key to ibuffer
, as I use it so often.)
n.b. You can use C-k and x in the regular list-buffers
to mark and kill buffers, but I think everyone should be using ibuffer
, really.
Upvotes: 16