Basic Line Editing Tricks for Powershell

Introduction

Powershell can be a great program with limitless possibilities, especially when dealing with remote server management. If you are constantly having to manage your server and find having to edit your commands lines time consuming, there is hope. This tutorial will provide you with a list of basic line editing tricks for Powershell to help speed up your workflow and productivity.

Command History

Before going over some of the line editing commands, we should introduce some important starter commands. The first is the get-history which will list all the commands in you command history. Just like getting the history you can clear your history list by entering clear-history. If you notice that when you get-history, each command has specified number. You can pass this command to invoke-history to run the command. If you want to use the command on line 20, just type in invoke-history 20

Line Editing Commands

‘ (Backwards apostrophe key) – Insert a line break or use it as an escape character to make a literal. Same as the pipe (|) character.

Alt + Space + E – Display an editing shortcut menu with Mark (press K), Copy (press Y), Paste (press P), Select All (press K), Scroll (press S), and Find (press F) options.

Alt + F7 – Clear the command history.

Ctrl + C – Exit the subprompt or terminate execution.

Ctrl+End – Delete all the characters in the line after the cursor.

Ctrl+Left arrow / Ctrl+Right arrow – Move left / right one word at a time.

Ctrl+S Pause or resume the display of output.

Delete / Backspace – Delete the character under the cursor / press Backspace to delete the character to the left of the cursor.

Home / End – Move to the beginning / move to the end of the line.

Insert – Switch between insert mode and overwrite mode.

Left / Right arrow keys – Move the cursor left or right on the current line.

Page Up / Page Down – Access the first or last command in the command history.

Right-click If QuickEdit is disabled, it will display an editing shortcut menu with Mark, Copy, Paste, Select All, Scroll, and Find options. To copy the screen buffer to the Clipboard, right-click, choose Select, and then press Enter.

Tab / Shift+Tab – Access the tab expansion function.

Up / Down arrow keys – Scan forward or backwards through your command history.
Esc – Clear the current line.

F1 – Move the cursor one character to the right on the command line. At the end, it inserts one character from the text of your last command.

F2 – Creates a new command line by copying your last command line up to the character you type.

F3 – Completes the command line with the content from your last command line, starting from the current cursor position to the end of the line.

F4 – Deletes characters from your current command line, starting from the current cursor position up to the character you type.

F5 – Scans backward through your command history.

F7 – Displays a pop-up window with your command history and allows you to select a command. Use the arrow keys to scroll through the list. Press Enter to select a command to run, or press the Right arrow key to place the text on the command line.

F8 – Uses text you've entered to scan backward through your command history for commands that match the text you've typed so far on the command line.

F9 – Runs a specific numbered command from your command history. Command numbers are listed when you press F7