4

In set -o vi mode in bash, when I press Esc+k to get the last entered command, and then A, I end up in the insert mode, which allows me to press backspace to start deleting the end of the last command.

With zsh in set -o vi mode, everything works up until the backspace part.

How can I fix this?

6

The quick answer, put this in your ~/.zshrc:

bindkey -v '^?' backward-delete-char

Normally '^?' (backspace) is bound to vi-backward-delete-char, which is supposed to have the behavior you observe, as that is how vi (not vim, unless in vi classic mode) behaves.

  • Hmm... vim does not allow erasing characters to the left after pressing A regardless of compatibility mode. – Kusalananda Jun 17 '16 at 12:46
  • @Kusalananda All of the vims I've used do. – PSkocik Jun 17 '16 at 12:50
  • We live in different worlds ;-) – Kusalananda Jun 17 '16 at 12:52
  • Note: busybox's vi departs from this traditional behavior and lets you delete characters to the left just fine after anything that puts you into insert mode, including A. (So I never knew about this old traditional vi behavior.) – mtraceur Mar 12 '17 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.