How can I delete all buffers in Kakoune?

Hey,

I know how to delete a single buffer. Or to repeat the command manually do delete multiple buffers. Or to exit Kakoune and enter again. But, is there a way to delete all buffers with a single command? Or is there a way to implement that easily with configuration?

Thank you!

The delete-buffer command only deletes a single buffer (the current buffer, by default).

evaluate-commands will run a command you give it, but if you use the -buffer NAME switch it will run the command the buffer named NAME, not in the current context. If you use the special name *, it will run the command in every open buffer.

So, the following command will delete every (unmodified) buffer:

evaluate-commands -buffer * delete-buffer
4 Likes

What if there is a file or buffer called exactly * ?

Then you can’t target it specifically; Kakoune checks for the special name * before checking for buffer names:

Right. And AFAICT, there’s also no way to switch to a buffer index (buffer 2) as in vim.

Just to mention that I really like the buffer switcher plugin, which I thin you can
use to implement both “delete all buffers but one”, or “jump to buffer by name” and more … after all, the buffer switcher is actually “just” an other text file !

1 Like