How can I clear the current line in the command prompt? (I'm using Windows 7.)

Too often, I enter a command, execute it, get many lines of output, then wish to enter another command. But before entering the second command, I press the up arrow key to review the first command, then I find I have to hold backspace for 30-or so characters. (I can't just press down again to get an empty line. Nor can I get it by pressing up again.)

  • @myrddim has it but that aside, some poor alternatives are keep tapping up until you have something short then hold backspace. another one is make the command be a bad command or filename, or rather, an "'sdfd' is not recognised as an internal or external command" so move the cursor a bit with left arrow and just tap a letter or don't and just tap a letter at the end, mess up the cmd input, then hit ENTER, get that error and the next line will be blank.
    – barlop
    Mar 5, 2012 at 18:55
  • 1
    @barlop That is indeed a poor workaround! It only takes one keystroke. If you can't use the Esc key, you could use AutoHotkey to simulate it.
    – iglvzx
    Mar 5, 2012 at 19:20

2 Answers 2


The Escape (Esc) key will clear the input line.

In addition, pressing Ctrl+C will move the cursor to a new, blank line. This may be helpful as the input you just reviewed remains visible while you type the new command.

  • 3
    And if you want to clear the whole screen, you can use the cls command. :)
    – iglvzx
    Mar 5, 2012 at 18:52
  • 11
    As a side note, on UNIX it's ctrl+u. Oct 22, 2012 at 23:12
  • 2
    Which would be relevant if the question wasn't specifically targeted at the Windows 7 command prompt. :-) Also, I believe this is shell specific, as I am reasonably certain some shells have the same behavior as Windows when pressing Ctrl+C. Oct 22, 2012 at 23:19
  • 2
    @MyrddinEmrys on Windows it is cls
    – CJ7
    Jun 1, 2016 at 5:24
  • 3
    Note: the CTRL+C command will also exit any command line session you are having, i.e python, and return you back to the command line environment. Jul 14, 2016 at 7:41

Aside from the two that Myyrddin covered - Esc and Ctrl+C - there are also two more shortcuts related to clearing the current input in CMD.

Ctrl+Home will clear all characters in the input before the cursor (equivalent to Ctrl+U in Bash)

Ctrl+End will clear all characters in the input after the cursor (equivalent to Bash's Ctrl+K)

Both are fairly useful and, once internalised and gotten used to, could speed up editing in CMD by quite a bit.

  • 2
    I didn't know about these keystrokes; thank you. May you get the upvotes you deserve. Jan 31, 2017 at 13:47
  • 1
    Same here. Being used to Bash I always wanted those. OP is my savior.
    – uranusjr
    Jul 25, 2017 at 15:57
  • 1
    From bash(1): (Ctrl)+(X), (Rubout) is defined to be backward-kill-line; i.e., kill backward to the beginning of the line; i.e., the same as (Ctrl)+(Home) in Windows CMD. “Rubout” may be Backspace or Delete, so try (Ctrl)+(X), (Backspace) and (Ctrl)+(X), (Delete). Also, (Ctrl)+(U) is unix-line-discard; i.e., kill backward from the insertion point (cursor) to the beginning of the line; i.e., also the same as (Ctrl)+(Home).  (Ctrl)+(K) is defined to be kill-line; i.e., kill the text from the insertion point to the end of the line; i.e., the same as (Ctrl)+(End) in Windows CMD. Aug 26, 2018 at 5:47
  • 2
    Just to be clear: (Ctrl)+(U) is a long-standing, general feature of Unix.  It works in old, non-Linux, non-GNU, non-bash systems; it works in vi; it works if you do cat > file123.  The others are specific to the bash command line. Jul 22, 2019 at 16:12
  • 2
    Shift+Home and Shift+End selects the same as above, instead of deleting it.
    – Dercsár
    Apr 30, 2022 at 19:00

You must log in to answer this question.

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