Equivalent of Vim's -O and -o?

I use vim’s -O and -o modes a lot, which open a window per file, e.g. vim -O *.py will open all files in the current directory ending with .py in its own vim window.

The solution for this isn’t straightforward, so I thought I’d ask if anyone else had written something before embarking on my own journey.

One reason it’s not straightforward is that Kakoune doesn’t have windows the same way Vim does.

If you start Kakoune with kak *.py then you’ll be editing the first file, and all the other files will be open in hidden buffers. You can switch between them with the :buffer command.

On the other hand, Kakoune comes with a :new command that will launch a new top-level window (as distinct from Vim’s windows, which are all inside a single top-level window). It would be pretty cool to have a command that would open all hidden buffers in new windows, but I’m not sure how to determine which buffers are hidden. The buffer in the current client (wherever you run the command from) is not hidden, but other buffers might be hidden, or they might already be visible in other windows.

I guess you’d have to use %val{client_list} to get the list of clients, do something with :eval -client X and %val{bufname} to get the active buffer for each client, subtract the active buffers from %val{buflist} to find the hidden buffers, and then for each hidden buffer do :new buffer Y to open a new client for it.

1 Like