9

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?

1

1 Answer 1

24

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.

5
  • Hmm... vim does not allow erasing characters to the left after pressing A regardless of compatibility mode.
    – Kusalananda
    Jun 17, 2016 at 12:46
  • 1
    @Kusalananda All of the vims I've used do. Jun 17, 2016 at 12:50
  • We live in different worlds ;-)
    – Kusalananda
    Jun 17, 2016 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, 2017 at 17:24
  • 1
    In vim (and neovim) this is configurable behavior, controlled by the 'backspace' option, when it includes start. See :h 'backspace' for details. neovim includes start in its defaults, but vim does not. Sep 8, 2019 at 17:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .