Bash/zsh: Undo erase backwards (ctrl+w)

In Bash and Zsh ctrl+w erases backwards from where the cursor is. Is it also possible to undo what I had erased?

Thanks!

1

4 Answers

Undo it's like this :ctrl + _

7

It's ctrl + /

ctrl + y (or _) pastes what's in the buffer. The buffer get's filled by things like ctrl + w. You can paste it in different places multiple times, so it's not an "undo". ctrl + / is undo, and you can execute it multiple times to undo every consecutive previous action.

This below shortcut key does the job of undo the erased string by ctrl+w,

ctrl+y

3

ctrl+w does not delete but cuts everything in front of the cursor. Therfore you can yank/paste it with ctrl-y assuming you did not move the cursor. ctrl+_ actually restores the line itself.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like