Command Line Keystrokes

Command Line Keystrokes

CLI Keystrokes

There are several Keyboard Shortcuts that are worth knowing, they make using the CLI much more pleasant and efficient, especially when correcting mistakes or building commands up by adding more options/commands. Most are the same for PowerShell and the CMD Command Prompt.

If you are using PowerShell and have the the PSReadline PowerShell module installed (standard with the PowerShell 5.1 that's included with Windows 10, installable for PowerShell 3.0+) there are many other helpful keyboard tricks.

You don't need to memorize all these, but the ones worth learning are listed here:

Keys Description or Action
Up / Down
Arrow
Scroll Back / Forward through your command history.
Eg. Press to quickly get back to your previous command, press it again to go further back
Home / End Jump to the Start / End of the command line with Home and End
Ctrl + Left / Right
Arrow
Jump Left / Right one whole word at a time using Ctrl+ / Ctrl+, otherwise move just one character at a time.
(And of course Del / Backspace as expected)
Tab / Shift-Tab Tab completion, as mentioned on the Essentials pages, for files (and command with PowerShell).
You can also cycle backwards with Shift-Tab
Esc Clear the current command line to start over with Esc (there is no undo!)
Enter All commands are only processed/run after you press Enter at the end of each command, or at the end of all the switches/options.
F7 In DOS/CMD: F7 Displays a pop-up window of your command history, use arrows and Enter to re-run a command.
Doesn't work in PowerShell with PSReadline, type history (or just h) to see your command history and re-run a command by number with r ##
Ctrl+C Stop/Cancel a long running command that you don't want to wait any longer for with Ctrl+C, with PSReadline it also copies to the clipboard.
(On older systems Ctrl+Break would exit your whole PowerShell session, but now it appears to do nothing).
Pause Pause a long running command that is scrolling information by too fast. Press any key to continue.
Another option is to pipe | it to more to show only one page at a time.
Mouse Right-Click Not a keystroke, but if Quick Edit Mode IS enabled it pastes from your clipboard. (enabled the same way for PowerShell)
If Quick Edit Mode is NOT enabled it pops up a menu from which you can choose Paste. With PSReadline you can use Ctrl+V to Paste too.

This is assuming the default console application in Windows - there are custom console apps which may have different keystrokes, but these would still be fairly common.