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

c-sel-r-reg () {
  zle select-in-word
zle -N c-sel-r-reg
bindkey "^[Oc" c-sel-r-reg

c-l-reg () {
  zle vi-backward-word
  zle end-of-line
  zle -U " "
zle -N c-l-reg
bindkey "^[Od" c-l-reg

1 Answer 1


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:


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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .