I made a plugin Kakoune Buffer Manager to manage buffers within the file

Hi,

This is my first week dive in Kakoune! I’m really enjoying learning Kakoune. but I didn’t find a proper plugin to manage buffers. So I made one:

https://github.com/theowenyoung/kakoune-buffer-manager/

kakoune-buffer-manager

You can use it by:

plug 'theowenyoung/kakoune-buffer-manager' config %{
    map global normal <c-a-b> ': buffer-manager<ret>' -docstring 'open buffer manager'
}

Why?

First I tried kakoune-buffers, it use user-mode to list or operate buffers, with this, I can’t see the status of buffers and switch at the same time. But I really need to know the status(is modified) of buffers when I operate them, and sometimes I need to multiple select them to close.

I think using *scratch* is the best way to manage buffers, with this, I can use all kakoune functions to navigate buffers. Use an intuitive way to manipulate buffers.

kakoune-buffer-switcher is a similar way to do this (Actually I stole its code), but it seems not to work with the latest Kakoune, and it’s a little simple for my use case. So I developed a buffer manager, it supports multiple selections!

Usage

<ret>: open buffer
d: delete current line or selected buffers
D: force delete current line or selected buffers
<esc>: back to last buffer
q: delete all buffers
Q: force delete all buffers
e: delete other buffers except selected buffers
E: force deleted other buffers except seleted buffers
<a-d>: delete selected buffers and back
<a-D>: force deleted seleted buffers and back
<?>: toggle show help info

I just released it and haven’t done much testing yet, but it functions fine on my computer! If you have a similar need, you can play fire with it.

2 Likes

This is really good, @theowenyoung!

Thank you so much for writing it :man_bowing:

One nitpick is that, for me, deleting multiple buffers by selecting the buffers one at a time, then pressing <d> only deletes the buffer of the main selection. I see that you’re using -itersel in the definition of buffer-manager-delete, so why it isn’t working doesn’t make sense to me.

Regardless, thanks for the plugin!

Thanks for the feedback. multiple selections work for me.

you can try running buffer-manager-select after selecting buffers, to see if the selection is all right. if it’s right, it should select the following selections:

Screen Shot 2022-09-22 at 04.46.25

Interesting…

I just made the command public and tried to run it manually. That’s definitely the issue:

image

image

I made a reproduction here, and fixed it now. please update to the latest version! Thanks.

I updated and tried out the fix, and it works perfectly. Thanks, Owen!