Change to unsaved buffer

Over the course of a few days, I can open several tens of files in kakoune. I tend to :q files I no longer need, but that doesn’t delete the buffer. When I want to restart kakoune (or the computer), I almost invariable get the message that a buffer xyz has not been saved.

I often have a hard time selecting that buffer, especially because I seldom write down the name and the prompt with the “offending” filename is lost when starting :buffer to switch. I sometimes just start to use :db to get rid of previously quit buffers, to get rid of the already saved ones.
It is no option to write-all-quit

Is there a command to go to any of the unsaved buffers? (which I can then save or delete without saving and move on). Or a way to select buffers where you can see which have not been saved. Or just delete all saved buffers in one go?

%val{modified} expands to true if the current buffer is unsaved. You could probably do something like (untested):

eval -buffer * %{
    eval %sh{
        if [ "$kak_modified" = "true" ]; then
            echo buffer "%{$kak_buffile}"

…which would take you to an unsaved buffer, if any.

1 Like