| description | Describes how to edit commands at the PowerShell command prompt. |
|---|---|
| Locale | en-US |
| ms.date | 02/24/2025 |
| online version | https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_line_editing?view=powershell-7.6&WT.mc_id=ps-gethelp |
| schema | 2.0.0 |
| title | about_Line_Editing |
Describes how to edit commands at the PowerShell command prompt.
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.
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.
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.
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.
To delete the character behind the cursor's position, press Backspace.
To delete the character at the cursor's position, press Delete.
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.
To change to overwrite mode, press Insert. To return to insert mode, press Insert again.
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.
- about_PSReadLine
- about_Tab_Expansion
- Get-PSReadLineOption
- Get-PSReadLineKeyHandler
- Set-PSReadLineOption
- Set-PSReadLineKeyHandler
- Using PSReadLine key handlers