`:q` closes the window

What happened?

Started trying out Doom Emacs recently, I close buffers with :q all the time in vim, did that in here too. If there are multiple panes/windows open, it works as expected but when only one window is open, emacs closes altogether.

What did you expect to happen?

I expected only the buffer in view to close. SPC-b-k achieves this in the single window mode. In multiple windows, it closes the buffer and leaves the arrangement intact.

I would love to know how to rebind/change the binding for :q to the same action that SPC-b-k does. I looked on the internet but to no avail. This document also is incomplete.

Steps to reproduce

Have one window open, press :q

System information


Loading data dump...

That’s what Vim does. See :help :q in Vim.

Quit the current window. Quit Vim if this is the last window.

Remap Emacs’ function invoked by the :q ex command (:help :q in Emacs to find out) to the function invoked by the SPC b k (SPC h c/M-x describe-key-briefly SPC b k to find out):

(map!
 [remap evil-quit] #'kill-current-buffer)
2 Likes

Thanks for the solution and also for the organic method for further ventures!!