3

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?

1
  • make question community wiki?
    – Macke
    Sep 28, 2010 at 18:16

3 Answers 3

9

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 + ->
1
  • +1 because you beat me to it. I wanted to write the exact same thing.
    – Bobby
    Sep 28, 2010 at 15:24
5

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.

0

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.

You must log in to answer this question.

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