provide-module expand %— define-command -hidden -params 1 expand-impl %{ # param expand or shrink evaluate-commands -itersel %sh{ sel="$kak_selection_desc" left=${sel%%,*} right=${sel##*,} left_d=${left#*.} right_d=${right#*.} if [ "$left_d" -gt "$right_d" ]; then # sel facing back if [ "$1" = 'expand' ]; then echo 'execute-keys "HL"' else echo 'execute-keys "LH"' fi elif [ "$left_d" -lt "$right_d" ]; then # sel facing forward if [ "$1" = 'expand' ]; then echo 'execute-keys "LH"' else echo 'execute-keys "HL"' fi else if [ "$1" = 'expand' ]; then echo 'execute-keys "LH"' else echo 'nop' fi fi } } define-command expand-selections %{ expand-impl expand } define-command shrink-selections %{ expand-impl shrink } map global object ': expand-selections' -docstring 'expand selections' map global object ': shrink-selections' -docstring 'shrink selections' —