9

In bash pressing CTRL + U clears the characters on the line before the current cursor position while in zsh this will clear the entire line. How do I clear the characters on the line before the current cursor position by pressing CTRL + U in zsh?

2
  • That's the default behaviour with both emacs and vim keybindings. What does bindkey "\Cu" report? – muru Jun 19 '18 at 11:17
  • 1
    Answer is simple: run bindkey \^U backward-kill-line . @muru "^U" backward-kill-line – menteith Jun 19 '18 at 11:18
6

Bash and zsh work slightly different here. In zsh, CTRL + U clears the entire line instead.

In your configuration .zsh put this lines:

bindkey -e
bindkey \^U backward-kill-line

You can use

$ bindkey

to list all of your keyboard shortcuts in zsh.

BTW: in bash you will print all bindkey with the following command:

bind -P

So no cheat sheets are necessary!

1

In zsh, Alt+W cuts everything from cursor position to the beginning of the line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.