3

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.

Jens
  • 69,818
  • 15
  • 125
  • 179
  • What terminal emulator are you using? What you describe as your desired behaviour works for me as is (gnome-terminal). – SBI May 24 '13 at 08:31
  • Do you have TERM=xterm set in your .zshrc? – SBI May 24 '13 at 08:42
  • I use `TERM=xterm-256color`. – Jens May 24 '13 at 08:58
  • Backspace being restricted to a single line is normal behavior for `vi`-like editors. Are you using `vi` mode? –  May 24 '13 at 09:01
  • @WumpusQ.Wumbley Yup, `bindkey -v`; with `bindkey -e` backspacing across lines works. Is there a way to have the behavior with -v? – Jens May 24 '13 at 09:24

1 Answers1

2

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.