Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top