Skip to content

Commit

Permalink
add killed regions to the kill ring (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
romkatv committed Feb 6, 2021
1 parent 0029ed6 commit 1254e2c
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions fn/-z4h-move-and-kill
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@
local -i cursor=CURSOR
"$@"
emulate -L zsh
if (( CURSOR > cursor )); then
BUFFER[cursor+1,CURSOR]=

local -i from to
if (( CURSOR < cursor )); then
from=CURSOR+1
to=cursor
else
from=cursor+1
to=CURSOR
CURSOR=$cursor
fi

if [[ $LASTWIDGET != ((z4h-|.|)(backward-|)kill-*|(.|)copy-region-as-kill) ]]; then
zle .copy-region-as-kill $BUFFER[from,to]
elif (( CURSOR < cursor )); then
BUFFER[CURSOR+1,cursor]=
CUTBUFFER=$BUFFER[from,to]$CUTBUFFER
else
CUTBUFFER+=$BUFFER[from,to]
fi

BUFFER[from,to]=
zle -f kill

0 comments on commit 1254e2c

Please sign in to comment.