about_Line_Editing
Short description
Describes how to edit commands at the PowerShell command prompt.
Long description
The PSReadLine module provides useful keyboard shortcuts to help you edit
commands at the PowerShell command prompt. The key bindings discussed in this
article are the default key bindings on Windows platforms. You can create
custom key bindings by using the Set-PSReadLineKeyHandler
command.
On non-Windows platforms, PSReadLine defaults to the Emacs
edit mode. You can
change the edit mode using the Set-PSReadLineOption
command. PSReadLine has
three edit modes: Emacs
, Vi
, and Windows
.
To see the current edit mode, use the Get-PSReadLineOption
command. To see a
list of the current key bindings, use the Get-PSReadLineKeyHandler
command.
Add a line
To add a line, press Shift+Enter.
You can add multiple lines. Each additional line begins with >>
, the
continuation prompt. Press Enter to execute the command.
Move left and right
To move the cursor one character to the left, press the LeftArrow.
To move the cursor one word to the left, press Ctrl+LeftArrow.
To move the cursor one character to the right, press the RightArrow.
To move the cursor one word to the right, press Ctrl+RightArrow.
Move to a line's beginning or end
To move to the beginning of a line, press Home.
To move to the end of a line, press End.
If lines were added, press Home or End twice to move to the beginning or end of the lines.
Delete characters
To delete the character behind the cursor's position, press Backspace.
To delete the character at the cursor's position, press Delete.
Delete characters from a line
To delete all the characters from the cursor's position to the end of a line, press Ctrl+End.
To delete all the characters from the cursor's position to the beginning of a line, press Ctrl+Home.
If lines were added, characters are deleted from the current line and the lines that were added.
Insert and overstrike mode
To change to overwrite mode, press Insert. To return to insert mode, press Insert again.
Tab completion
To complete a cmdlet name, a parameter, or a path, press the Tab key. To scroll through a list of values, press the Tab key again.