I am using ZSH on Mac terminal and I enable vi mode in the terminal by adding set -o vi
to my ~/.zshrc
. When I am in the prompt line, and I type Hello
, then I hit Esc
to enter the non-insert mode, move my cursor to e
and hit i
to enter insert mode, I can not erase the H
by hitting the backspace
key.
Note that backspace key works on this same scenario when I open up a new file using vim test.txt
and writing Hello
and following the steps above, so I don't think this is a vim settings issue.
Also, I ran vi --version
in my ~/.zshrc
right before set -o vi
and this is part of the output I got: VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Feb 10 2024 02:02:30)
Please help me!
Try bindkey -M viins "^?" backward-delete-char
.
Backspace is normally bound to vi-backward-delete-char
, which is specifically documented to not do what you’re asking:
vi-backward-delete-char (unbound) (X) (^H)
Delete the character behind the cursor, without changing lines. If in insert mode, this won't delete past the point where insert mode was last entered.
backward-delete-char
doesn’t have that restriction.