Replacement for vim -p

I’m trying to migrate from vim to kakoune, but I haven’t found a (good) way to emulate vim -p (open files in tab).

Currently I’m hacking it with a custom bash script using either xfce4-terminal or suckless tabbed. Is there better way?

I want it to support (internal) paste register or command history.

As you’ve no doubt noticed, Kakoune doesn’t do tabs — so there’s no direct way to create tabs as such, although your window manager or terminal may provide a way to (temporarily) say “the next few windows that open should be tabbed together”.

If you can provide your own tabbing system, I would teach Kakoune to open a window for each buffer, something like :bufdo tab split in Vim.

Perhaps something like this (untested) command might work:

define-command open-buffers-in-windows %{
    eval %sh{
        # A helper that quotes arguments the way Kakoune expects
        kakquote() {
            for arg; do
                printf "%s" "$arg" | sed -e "s/'/''/g; 1s/^/'/; \$s/\$/' /"
            done
            echo
        }

        # Set the shell's argument list to be Kakoune's buffer list
        eval set -- "$kak_quoted_buflist"

        # For each buffer in the buffer list...
        for each; do
            # ...if this is the buffer than was active when
            # this command was invoked, it's already in a window,
            # we don't need to create a new one.
            [ "$kak_buffile" = "$each" ] && continue

            # ...if this buffer's name begins with an asterisk,
            # it's probably a scratch buffer like *debug*, and we
            # don't need to open a window for it.
            case "$each" in
                 "*"*) continue ;;
            esac

            # ...otherwise, tell Kakoune to open a new window
            # and switch to this buffer
            kakquote new buffer "$each"
        done
    }
}

Once you have that in your kakrc, you should be able to tell Kakoune to load a bunch of files then execute the command like this:

kak -e open-buffers-in-windows file1.txt file2.txt file3.txt

If you happen to be using the i3 window manager, you could write a script that runs:

i3-msg split vertical
i3-msg layout tabbed

…before invoking Kakoune as above, so that all the windows it creates wind up tabbed together in the same frame. If you’re not using i3, I’m sure your preferred tool has some similar functionality.

Kakoune does not have inbuilt windowing capabilities. So there are no tabs in Kakoune, only buffers. Most modern text editors feature tabs, as a way to switch between active files. That’s what old editors called buffers. So if you want some buffer to be opened in split, or new window, that is either floating or tabbed, you should refer to facilities of your terminal or window manager. I’m using Tmux for this, and I have runtime commands spli vsplit and tabnew. What you’re referring to is however, opening multiple files in separate windows, and I’m not sure if you want exactly this. When you do this in Vim, it creates fake tab for each file, and displays those on top of Vim. This is wrong approach to use Vim, and what you’re really want is :set hidden (in Vim), so you can switch between unsaved buffers, just like between tabs in any other editors. But if you only want clickable visual indication of all opened buffers on the top of the editor, you’ll have to use Tmux, tabs in terminal, suckless tabbed, i3wm’s tabs or any other tab solution in window manager

By the way, you don’t want to use tabs in Vim, since tabs are viewports and used to change window configurations with different splits. Buffers are tabs both in Vim and Kakoune.