8

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?

Petr Skocik
  • 28,176
  • 14
  • 81
  • 141

1 Answers1

23

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.

phemmer
  • 70,657
  • 19
  • 188
  • 223
  • Hmm... `vim` does not allow erasing characters to the left after pressing `A` regardless of compatibility mode. – Kusalananda Jun 17 '16 at 12:46
  • 1
    @Kusalananda All of the vims I've used do. – Petr Skocik 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
  • 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. – John Whitley Sep 08 '19 at 17:13