Editing the Command Line
When working at a command prompt, you often enter the same command several times, or enter several similar commands. If you make a mistake when typing a command line, you don't want to retype the whole thing-you just need to fix the part that was wrong. Windows includes a feature that recalls previous commands and allows you to edit them on the current command line. Table below lists these editing keys and what they do.
Command-Line Editing Keys
Key | Function |
Up Arrow | Recalls the previous command in the command history |
Down Arrow | Recalls the next command in the command history |
Page Up | Recalls the earliest command used in the session |
Page Down | Recalls the most recent command used |
Left Arrow | Moves left one character |
Right Arrow | Moves right one character |
Ctrl+Left Arrow | Moves left one word |
Ctrl+Right Arrow | Moves Right one word |
Home | Moves to the beginning of the line |
End | Moves to the end of the line |
Esc | Clears the current command |
F7 | Displays the command history in a scrollable pop-up box |
F8 | Displays commands that start with characters currently on the command line |
Alt+F7 | Clears the command history |
The command-line recall feature maintains a history of the commands entered during the Command Prompt session. To display this history, press F7, which opens a window that shows your recently entered commands. Scroll through the history with the arrow keys, and then press Enter to reuse the selected command, or press the Left Arrow key to place the selected text on the command line without executing the command. (This allows you to edit the command before executing it.)
It's not necessary to display the pop-up window to use the command history. You can scroll through the history within the Command Prompt window with the Up Arrow and Down Arrow keys.
The F8 key provides a useful alternative to the Up Arrow key. The Up Arrow key moves you through the command history to the top of the command buffer and then stops. F8 does the same, except that when you get to the top of the buffer, it cycles back to the bottom. Furthermore, F8 displays only commands in the buffer that begin with whatever you typed before you pressed F8. Type d at the command prompt (don't press Enter), and then press F8 a few times. You'll cycle through recently entered commands that start with d, such as Dir and Del. Now type e (after the d), and press F8 a few more times. You'll cycle through Del commands along with any others that start with de. You can save a lot of keystrokes using F8 if you know the first letters of the command you're looking for.
In this tutorial:
- Working with the Command Prompt
- Starting and Ending a Command Prompt Session
- Easy ways to invoke administrator Command Prompt sessions
- Starting Command Prompt at a Particular Folder
- Strings with Spaces Need Quotes
- Cmd.exe vs. Command.com
- Commands Are Not Case Sensitive
- Starting Command Prompt and Running a Command
- Cmd.exe and Other Command Prompts
- Using AutoRun to Execute Commands When Command Prompt Starts
- Using Cmds Command-Line Syntax
- Using Commands
- Type /? for help
- Starting Programs
- Open Windows Explorer at the current Command Prompt folder
- Using File-Name and Folder-Name Completion
- Use a different completion character
- Using Wildcards
- Editing the Command Line
- Using Command Symbols
- The Redirection Symbols
- The Pipe Symbol
- The Command Combination Symbols
- Pausing or Canceling Commands
- Simplifying Command Entry with Doskey Macros
- DOSKEY Saves Typing
- System Variables Identify the Environment
- Viewing Environment Variables
- Modifying Environment Variables
- Predefined Environment Variables
- Customizing Command Prompt Windows
- Setting the Window Size and Position
- Setting the Window Size and Position Visually
- Selecting a Font
- Setting Colors
- Setting Other Options
- Copy and paste in the command prompt window
- Navigating from the command prompt
- Printing a list of filenames
- Commands Use Paths
- Identifying Executables
- Modifying the Path to Executables
- Modifying the Path with the GUI
- Changing the Current Path with CD
- Changing the Current Path with Windows Explorer
- Capturing the Output
- A Sampling of Commands
- Dir
- Copy
- XCopy
- SET
- NET USE
- SystemInfo
- DriverQuery
- Echo
- Advanced Shell Commands
- Creating a Batch File
- Scheduling a Batch File
- Creating Scheduled Tasks with a Script
- Using Windows PowerShell and the PowerShell ISE
- Windows PowerShell ISE
- PowerShell Commands
- Verbs and Nouns
- Sending Output to a Text File
- PowerShell Syntax
- Variables Created with a $ Symbol
- Comparison Operators
- Parentheses, Brackets, and Braces
- Running PowerShell Scripts
- PowerShell Execution Policy
- Changing the Execution Policy
- Looping
- Collections
- Creating a PowerShell Script
- Documenting Scripts
- Using PowerShell Commands
- Getting Help on PowerShell
- Using WMI_Cmdlets
- Getting Details on an Object
- Querying Information on Specific Objects
- Terminate Applications with Win32_process
- Formatting Output with the -f Format Operator
- Filtering the Output with the Where-Object Command
- Using the IF statement
- Using the Switch Statement
- Script Reusability