1

zle widgets working by Ctrl-Right keys, Ctrl-Left keys (first widget is starting selection mode):

c-sel-r-reg () {
  local WORDCHARS=${WORDCHARS/\/}
  zle select-in-word
}
zle -N c-sel-r-reg
bindkey "^[Oc" c-sel-r-reg

c-l-reg () {
  local WORDCHARS=${WORDCHARS/\/}
  zle vi-backward-word
  zle end-of-line
  zle -U " "
}
zle -N c-l-reg
bindkey "^[Od" c-l-reg
2

To cancel what you're calling "selection mode" from a zsh zle widget, it is:

zle set-mark-command -n -1

or if you prefer:

REGION_ACTIVE=0

What zsh supports comes in mostly emacs and vim compatible forms. Text between the mark ($MARK) and cursor ($CURSOR) is highlighted. Documentation also talks about the region (emacs) or visual mode (vim). The typical behaviour that you get with Windows programmes is not especially powerful. You'd be better off learning how vim or emacs does things but a Windows style selection could be mostly emulated if you replace a few widgets. e.g. self-insert would need to clear the selection before inserting text. The main limitation is that the selection will need to always either begin or end at the cursor.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.