I am learning terminal tips. In this tutorial, the guy says that Ctrl + U deletes everything from the cursor until the end of line. In my case, it always deletes the whole line. I am using zsh on macOS.

  • 1
    Actually, he says Ctrl-U kills to the beginning of the line. 2:40 into the video. Jun 3, 2019 at 18:03
  • @JohanMyréen so how can I delete text from the course back to the beginning of the line ? Jun 3, 2019 at 18:17
  • Ctrl-U deletes between the cursor and the beginning of the line. Of course, if the cursor is at the end of the line then the whole line is deleted. Jun 3, 2019 at 18:54
  • 3
    @JohanMyréen that's not my case, even if the course in the middle of the line, Ctrl + U still deletes the whole line Jun 3, 2019 at 20:59
  • The equivalent of Ctrl-U on zsh is Ctrl-W. This is why is "doesn't work" as expected. Found it on this askubuntu thread: askubuntu.com/questions/1047849/…
    – itMaxence
    Apr 4, 2023 at 16:16

2 Answers 2


First map the key binding by typing bindkey \^U backward-kill-line. Then test to see if this worked. If it works, make it permanent by adding the same line to an appropriate zsh RC file.

echo 'bindkey \^U backward-kill-line' >> ~/.zshrc

The Z Shell Manual, section 18.6.3, defines the "widgets," such as backward-kill-line.

  • 1
    it works! cool! Jan 13, 2021 at 11:05

if youre talking about GNU readline in the shell you will want to use Ctrl+K to kill to the endof the line.

Alternatively you can also use Alt+D to incremently kill on a breaking point

Edit: Just realized you're using zsh on Mac. The only server I haveusing zsh is in the cloud. Ill test real quick and verify.

Edit: Yes still works for me on Linux Ubuntu. Note that I installed zsh (and fish which is quite nice) on that machine about 2 weeks ago and never made a zshrc file. So there has been no special customizations as far as I can tell. Im guessing all these ZSH questions are in regards to what I heard was Apple leaving their ancient version of bash finally because they found something they can conveniently use

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .