Hi Ben, here is the command and link for sed ‘s/^\s*//g’.
below is untested, but its a place to start experimenting with.
map global user 'r' -docstring "send-text ^\s+" \
%{: send-text %sh{printf %s ${kak_selection} | sed 's/^\s*//g' }<ret>}
the above is a hack-able file that you can copy and rename it then place the file in your .config/kak/*
path. Just change the define-command names so no clashing, check kak buffer *debug*
for any issues.
If all else fails just head back here in a couple of days and post the next problem you have with it.
Have fun