Answers:
一种方法是
这是一个概念证明(for xterm
),适用于:
Shift-Left
并且Shift-Right
:分别开始向左/右选择,Left
,Right
:取消选择并分别向左/向右移动,Delete
:删除选择,如果有,否则光标下的字符。通常的免责声明适用(可能有其他更好的方式,你的猫可能会吃你的烤面包机等)。
bindkey -e
function zle-line-init {
marking=0
}
zle -N zle-line-init
function select-char-right {
if (( $marking != 1 ))
then
marking=1
zle set-mark-command
fi
zle .forward-char
}
zle -N select-char-right
function select-char-left {
if (( $marking != 1 ))
then
marking=1
zle set-mark-command
fi
zle .backward-char
}
zle -N select-char-left
function forward-char {
if (( $marking == 1 ))
then
marking=0
NUMERIC=-1 zle set-mark-command
fi
zle .forward-char
}
zle -N forward-char
function backward-char {
if (( $marking == 1 ))
then
marking=0
NUMERIC=-1 zle set-mark-command
fi
zle .backward-char
}
zle -N backward-char
function delete-char {
if (( $marking == 1 ))
then
zle kill-region
marking=0
else
zle .delete-char
fi
}
zle -N delete-char
bindkey '^[[1;2D' select-char-left # assuming xterm
bindkey '^[[1;2C' select-char-right # assuming xterm