feat: change from emacs mode to vi mode

This commit is contained in:
2025-10-20 02:45:56 +02:00
parent 47f2852064
commit 1915036a5e
+28 -2
View File
@@ -30,8 +30,34 @@ setopt HIST_REDUCE_BLANKS
setopt HIST_VERIFY
setopt INC_APPEND_HISTORY_TIME
# Emacs mode
bindkey -e
###########
# Vi mode #
###########
bindkey -v
export KEYTIMEOUT=1 # Reduce ESC delay to 10ms
bindkey -v '^?' backward-delete-char # Make backspace work in vi insert mode
bindkey -v '^H' backward-delete-char # Alternative backspace binding
bindkey -a '_' vi-first-non-blank
# Selection highlight
# shellcheck disable=SC2034
zle_highlight=(region:bg=#323641)
# Change cursor shape based on vi mode
function zle-keymap-select {
if [[ ${KEYMAP} == main ]]; then
echo -ne '\e[5 q' # Beam cursor for insert mode
elif [[ ${KEYMAP} == vicmd ]]; then
echo -ne '\e[1 q' # Block cursor for command mode
fi
}
zle -N zle-keymap-select
function zle-line-init {
echo -ne '\e[5 q' # Beam cursor for insert mode
}
zle -N zle-line-init
###################
# Shell Variables #