Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

With cmd.exe, when something's wrong with what I typed? What edit option can I do? I can use arrow key to move cursor one by one, but it would be great if there's a key for

  • Move the cursor to the start of line
  • Move the cursor to the end of line
  • Move the cursor by the word not by character both directions (forward/backward)
  • Delete the word (not a character) under the cursor.

Or, what would be other useful keys for editing?

share|improve this question
    
make question community wiki? –  Macke Sep 28 '10 at 18:16

3 Answers 3

up vote 9 down vote accepted

I know you can do three of the four you requested:

  • Move the cursor to the start of line: Home
  • Move the cursor to the end of line: End
  • Move the cursor by the word not by character both directions (forward/backward): Ctrl + <- or Ctrl + ->
share|improve this answer
    
+1 because you beat me to it. I wanted to write the exact same thing. –  Bobby Sep 28 '10 at 15:24

Esc - clears line (like Ctrl+U in bash). F7 shows you current session history. F3 - completion from previous command. F4 - delete to character. So you can place cursor at the beginning of word hit F4 and than character that will delimit your deletion.

share|improve this answer

The command prompt (cmd.exe) has built-in doskey features (doskey was like a TSR that needed to be run from autoexec.bat in the original DOS OS), so most of the doskey features described here (at least those that are applicable to the cursor movement/history editing) are still valid. The previous answers mention most of these, but there are more (e.g., F9 to recall by history number).

There are also couple of more that are not in the doskey help that I accidentally stumbled upon, and I find them extremely useful especially when in the middle of long lines (very common to encounter if you are a developer). These are:

  • Ctrl+End: Clear to the end of the line
  • Ctrl+Home: Clear to the beginning of the line

E.g., if you want to remove the last two arguments after recalling a past command-line, all you have to do is press Ctrl+Left twice and press Ctrl+End to clear.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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