Hello zsh-users, I'm trying to write a function that selects the nth argument in the buffer. I would use it like `3gva` to select the 3rd argument. Here's the widget I have so far: function select-n-shell-word { if [[ -z "$NUMERIC" ]]; then NUMERIC=1; fi zle vi-beginning-of-line zle visual-mode zle select-a-shell-word for ((i = 1; i < $NUMERIC; i = i + 1)); do zle deactivate-region zle vi-forward-char -n 2 zle visual-mode zle select-a-shell-word done } zle -N select-n-shell-word bindkey -M vicmd "gva" select-n-shell-word Given the command line `echo these are arguments`, I would expect the command `3gva` to select like this: echo these[ are] arguments and indeed that's what happens if I run the following commands (emualating the for loop myself): - :vi-beginning-of-line - :visual-mode - :select-a-shell-word - :deactivate-region - 2:vi-forward-char - :visual-mode - :select-a-shell-word - :deactivate-region - 2:vi-forward-char - :visual-mode - :select-a-shell-word Nevertheless, when I run the command `3gva` it selects like this: [echo these are] arguments Does anybody know what's going on here? Thanks, Daniel
Attachment:
signature.asc
Description: This is a digitally signed message part