It was irritating me, how new
command causes seemingly random buffer to open up, so I created a command which creates identical copy of current window.
define-command split -params 0 -docstring \
"Creates new client with current buffer" \
%{
new %sh{
line=$(echo "$kak_window_range" | cut -d' ' -f 1)
column=$(echo "$kak_window_range" | cut -d' ' -f 2)
printf 'buffer -- %s;' "$kak_bufname"
printf 'execute-keys %s jvt;' "$line"
printf 'select -- %s;' "$kak_selection_desc"
printf 'execute-keys V %s <esc>;' "$(printf "%""$column""s" | tr ' ' 'l')"
}
}
I can’t guarantee that windows will be identical in case if your windows manager doesn’t ensure that the new kakoune window is equally sized as the original.
Personally I use tiling WM, which divides old windows space in half, to make space for the new buffer. It works great with such setup.
Edit: Took inspiration from @Screwtapello’s suggestion and also upgraded command to take in account the view’s horizontal alignment.