Jens
Jens

Reputation: 72707

zsh: How to backspace through to the previous line?

When I type a multiline command like

$ for i in 1 2 3; do
for> echo $i
for> done
1
2
3

and then recall the command with up-arrow, backspacing stops at the start of the last line (i.e. after erasing done). Is there a way to make the zsh line editor keep backspacing by jumping to the end of echo $i and erasing the previous line? I know I can use up-arrow, but I would like to just keep backspacing. Interestingly, this works for word-erase with Ctrl-W but not for backspace.

Upvotes: 3

Views: 1838

Answers (1)

user2404501
user2404501

Reputation:

When you run bindkeys -v all the keys are set to vi-like behavior, including the backspace key which is bound to vi-backward-delete-char. You can override specific keys afterward, like this:

bindkey '^h' backward-delete-char

or perhaps ^? instead of ^h - type Ctrl-V Backspace to get the right code.

Upvotes: 2

Related Questions