In Terminal, how to erase typed command quickly

terminal

In Terminal, let's say I type a long command, but before I press Enter, I decide that actually I don't want to run this command, and want to run another new command instead.

In such case, how to quickly remove everything I have typed, so that I can start typing the new command?

Pressing Delete for a few long seconds is not a good solution, I am looking for something faster.

Best Answer

You can cancel current command with ⌃ CTRL+c. You can clear command to the beginning with ⌃ CTRL+u. To clear line after the cursor press ⌃ CTRL+K.

Here are some great answers on StackOverflow.