zshrc.d/60-vi-showmode.zrc
changeset 47 f25fda256b1d
parent 45 c8b92fa96f48
child 50 87b60a3c90ae
--- a/zshrc.d/60-vi-showmode.zrc	Sat Aug 22 12:02:41 2020 +0200
+++ b/zshrc.d/60-vi-showmode.zrc	Sun Apr 25 13:40:43 2021 +0200
@@ -179,6 +179,11 @@
 ###
 
 vi-replace() {
+   if [[ $ZLE_STATE == *overwrite* ]]; then # Switch back to insert mode
+       builtin zle .vi-insert
+       redisplay-insert
+       return
+   fi
    show_mode "$__string_replace"
    builtin zle .vi-replace
 }
@@ -211,7 +216,7 @@
 bindkey -M vicmd 'guw'   down-case-word
 bindkey -M vicmd 'gUw'   up-case-word
 
-bindkey -M vicmd "^[[2~" vi-insert
+bindkey -M vicmd '^[[2~' vi-insert
 bindkey -M vicmd 'q'     push-line
 
 # Specific to insert mode
@@ -221,6 +226,8 @@
 bindkey -M viins '^[[5~' history-beginning-search-backward # PgUp
 bindkey -M viins '^[[6~' history-beginning-search-forward  # PgDn
 
+bindkey -M viins '^[[2~' vi-replace
+
 bindkey -M viins '^[[A'  up-line-or-history
 bindkey -M viins '^[[B'  down-line-or-history
 
@@ -256,7 +263,7 @@
 bindkey '^I' ft-complete
 
 
-if [[ -z ${TERM:#screen} ]]; then
+if [[ $TERM == screen* || $TERM == tmux* ]]; then
   bindkey -M viins '^[[1~'  beginning-of-line   # Home
   bindkey -M vicmd '^[[1~'  beginning-of-line   # Home
   bindkey -M viins '^[[4~'  end-of-line         # End