about_PSReadLine_Functions
PSReadLine provides an improved command-line editing experience in the PowerShell console.
PowerShell 7.3 ships with PSReadLine 2.2.6. The current version is PSReadLine 2.3.4. The current version of PSReadLine can be installed and used on Windows PowerShell 5.1 and newer. For some features, you need to be running PowerShell 7.2 or higher.
This article documents the functions provided by PSReadLine 2.3.4. These functions can be bound to keystrokes for easy access and invocation.
The following functions are available in the class Microsoft.PowerShell.PSConsoleReadLine.
Abort current action, for example: incremental history search.
- Emacs mode:
Ctrl+g
- Vi insert mode:
Ctrl+g
- Vi command mode:
<Ctrl+g>
Attempt to execute the current input. If it can be executed (like AcceptLine), then recall the next item from history the next time ReadLine is called.
- Emacs mode:
Ctrl+o
Attempt to execute the current input. If the current input is incomplete (for example there's a missing closing parenthesis, bracket, or quote) then the continuation prompt is displayed on the next line and PSReadLine waits for keys to edit the current input.
- Windows mode:
Enter
- Emacs mode:
Enter
- Vi insert mode:
Enter
The continuation prompt is displayed on the next line and PSReadLine waits for keys to edit the current input. This is useful to enter multi-line input as a single command even when a single line is complete input by itself.
- Windows mode:
Shift+Enter
- Emacs mode:
Shift+Enter
- Vi insert mode:
Shift+Enter
- Vi command mode:
<Shift+Enter>
Delete the character before the cursor.
- Windows mode:
Backspace
,Ctrl+h
- Emacs mode:
Backspace
,Ctrl+Backspace
,Ctrl+h
- Vi insert mode:
Backspace
- Vi command mode:
<X>
,<d,h>
Like BackwardKillInput - deletes text from the point to the start of the input, but doesn't put the deleted text in the kill-ring.
- Windows mode:
Ctrl+Home
- Vi insert mode:
Ctrl+u
,Ctrl+Home
- Vi command mode:
<Ctrl+u>
,<Ctrl+Home>
Like BackwardKillLine - deletes text from the point to the start of the line, but doesn't put the deleted text in the kill-ring.
- Vi command mode:
<d,0>
Deletes the previous word.
- Vi command mode:
<Ctrl+w>
,<d,b>
Clear the text from the start of the input to the cursor. The cleared text is placed in the kill-ring.
- Emacs mode:
Ctrl+u
,Ctrl+x,Backspace
Clear the text from the start of the current logical line to the cursor. The cleared text is placed in the kill-ring.
- Function is unbound.
Clear the input from the start of the current word to the cursor. If the cursor is between words, the input is cleared from the start of the previous word to the cursor. The cleared text is placed in the kill-ring.
- Windows mode:
Ctrl+Backspace
,Ctrl+w
- Emacs mode:
Alt+Backspace
,Escape,Backspace
- Vi insert mode:
Ctrl+Backspace
- Vi command mode:
<Ctrl+Backspace>
Replaces the character in front of the cursor.
- Vi command mode:
<c,h>
Cancel the current input, leaving the input on the screen, but returns back to the host so the prompt is evaluated again.
- Vi insert mode:
Ctrl+c
- Vi command mode:
<Ctrl+c>
Added in PSReadLine 2.3.0
Convert the first character of the next word to upper case and the remaining characters to lower case.
- Emacs mode:
Alt+c
,Escape,c
Copy selected region to the system clipboard. If no region is selected, copy the whole line.
- Windows mode:
Ctrl+C
If text is selected, copy to the clipboard, otherwise cancel the line.
- Windows mode:
Ctrl+c
- Emacs mode:
Ctrl+c
Delete selected region placing deleted text in the system clipboard.
- Windows mode:
Ctrl+x
Delete the character under the cursor.
- Windows mode:
Delete
- Emacs mode:
Delete
- Vi insert mode:
Delete
- Vi command mode:
<Delete>
,<x>
,<d,l>
,<d,Spacebar>
Delete the character under the cursor, or if the line is empty, exit the process.
- Emacs mode:
Ctrl+d
Deletes to the end of the multiline buffer.
- Vi command mode:
<d,G>
Delete to the end of the word.
- Vi command mode:
<d,e>
Deletes the current logical line of a multiline buffer, enabling undo.
- Vi command mode:
<d,d>
,<d,_>
Deletes from the first non-blank character of the current logical line in a multiline buffer.
- Vi command mode:
<d,^>
Deletes the current and next n logical lines in a multiline buffer.
- Vi command mode:
<d,j>
Deletes the previous requested logical lines and the current logical line in a multiline buffer.
- Vi command mode:
<d,k>
Deletes from the beginning of the buffer to the current logical line in a multiline buffer.
As most Vi commands, the <d,g,g>
command can be prepended with a numeric
argument that specifies an absolute line number, which, together with the
current line number, make up a range of lines to be deleted. If not specified,
the numeric argument defaults to 1, which refers to the first logical line in a
multiline buffer.
The actual number of lines to be deleted from the multiline is computed as the difference between the current logical line number and the specified numeric argument, which can thus be negative. Hence the relative part of method name.
- Vi command mode:
<d,g,g>
Delete to the end of the line.
- Vi command mode:
<D>
,<d,$>
Delete the next word.
- Vi command mode:
<d,w>
Added in PSReadLine 2.3.0
Convert the next word to lower case.
- Emacs mode:
Alt+l
,Escape,l
Like KillLine - deletes text from the point to the end of the input, but doesn't put the deleted text in the kill-ring.
- Windows mode:
Ctrl+End
- Vi insert mode:
Ctrl+End
- Vi command mode:
<Ctrl+End>
Deletes text from the point to the end of the current logical line, but doesn't put the deleted text in the kill-ring.
- Function is unbound
A new empty line is created above the current line regardless of where the cursor is on the current line. The cursor moves to the beginning of the new line.
- Windows mode:
Ctrl+Enter
A new empty line is created below the current line regardless of where the cursor is on the current line. The cursor moves to the beginning of the new line.
- Windows mode:
Shift+Ctrl+Enter
Invert the case of the current character and move to the next one.
- Vi command mode:
<~>
Clear the input from the cursor to the end of the input. The cleared text is placed in the kill-ring.
- Emacs mode:
Ctrl+k
Kill the text between the cursor and the mark.
- Function is unbound.
Clear the input from the cursor to the end of the current word. If the cursor is between words, the input is cleared from the cursor to the end of the next word. The cleared text is placed in the kill-ring.
- Windows mode:
Alt+d
,Ctrl+Delete
- Emacs mode:
Alt+d
,Escape,d
- Vi insert mode:
Ctrl+Delete
- Vi command mode:
<Ctrl+Delete>
Paste text from the system clipboard.
- Windows mode:
Ctrl+v
,Shift+Insert
- Vi insert mode:
Ctrl+v
- Vi command mode:
<Ctrl+v>
Important
When using the Paste function, the entire contents of the clipboard buffer is pasted into the input buffer of PSReadLine. The input buffer is then passed to the PowerShell parser. Input pasted using the console application's right-click paste method is copied to the input buffer one character at a time. The input buffer is passed to the parser when a newline character is copied. Therefore, the input is parsed one line at a time. The difference between paste methods results in different execution behavior.
Paste the clipboard after the cursor, moving the cursor to the end of the pasted text.
- Vi command mode:
<p>
Paste the clipboard before the cursor, moving the cursor to the end of the pasted text.
- Vi command mode:
<P>
Prepend a '#' and accept the line.
- Vi command mode:
<#>
Undo an undo.
- Windows mode:
Ctrl+y
- Vi insert mode:
Ctrl+y
- Vi command mode:
<Ctrl+y>
Repeat the last text modification.
- Vi command mode:
<.>
Replace the current character with the next set of characters typed.
- Vi command mode:
<c,l>
,<c,Spacebar>
Replace the current character with only one character.
- Vi command mode:
<r>
Reverts all input to the current input.
- Windows mode:
Escape
- Emacs mode:
Alt+r
,Escape,r
Clear the input from the start of the current word to the cursor. If the cursor is between words, the input is cleared from the start of the previous word to the cursor. The cleared text is placed in the kill-ring.
Function is unbound.
Clear the input from the cursor to the end of the current word. If the cursor is between words, the input is cleared from the cursor to the end of the next word. The cleared text is placed in the kill-ring.
Function is unbound.
Swap the current character and the one before it.
- Emacs mode:
Ctrl+t
- Vi insert mode:
Ctrl+t
- Vi command mode:
<Ctrl+t>
Undo a previous edit.
- Windows mode:
Ctrl+z
- Emacs mode:
Ctrl+_
,Ctrl+x,Ctrl+u
- Vi insert mode:
Ctrl+z
- Vi command mode:
<Ctrl+z>
,<u>
Undo all previous edits for line.
- Vi command mode:
<U>
Clear the input from the start of the current word to the cursor. If the cursor is between words, the input is cleared from the start of the previous word to the cursor. The cleared text is placed in the kill-ring.
- Emacs mode:
Ctrl+w
Added in PSReadLine 2.3.0
Convert the next word to upper case.
- Emacs mode:
Alt+u
,Escape,u
Attempt to execute the current input. If the current input is incomplete (for example there's a missing closing parenthesis, bracket, or quote) then the continuation prompt is displayed on the next line and PSReadLine waits for keys to edit the current input.
- Emacs mode:
Ctrl+m
Accept the line and switch to Insert mode.
- Vi command mode:
<Enter>
Like DeleteCharOrExit in Emacs mode, but accepts the line instead of deleting a character.
- Vi insert mode:
Ctrl+d
- Vi command mode:
<Ctrl+d>
A new line is inserted below the current line.
- Vi command mode:
<o>
Deletes the previous word, using only whitespace as the word delimiter.
- Vi command mode:
<d,B>
Moves the cursor back to the beginning of the previous word, using only whitespace as delimiters.
- Vi command mode:
<B>
Delete backward to the beginning of the previous word, as delimited by white space, and enter insert mode.
- Vi command mode:
<c,B>
Replaces the line left of the cursor and all of the way to the beginning.
- Vi command mode:
<c,0>
Replaces the line left of the cursor and all but one character to the beginning of the line.
- Vi command mode:
<c,^>
Replace the previous word.
- Vi command mode:
<c,B>
Find the matching brace, parenthesis, or square bracket and delete all contents within, including the brace.
- Vi command mode:
<d,%>
Delete to the end of the word.
- Vi command mode:
<d,E>
Delete the next glob (whitespace delimited word).
- Vi command mode:
<d,W>
Deletes until given character.
- Vi command mode:
<d,t>
Deletes until given character.
- Vi command mode:
<d,T>
Deletes until given character.
- Vi command mode:
<d,f>
Deletes backwards until given character.
- Vi command mode:
<d,F>
Switch to Insert mode and position the cursor at the beginning of the line.
- Vi command mode:
<I>
Switch to Insert mode and position the cursor at the end of the line.
- Vi command mode:
<A>
A new line is inserted above the current line.
- Vi command mode:
<O>
Append from the current line position.
- Vi command mode:
<a>
Delete the current character and switch to Insert mode.
- Vi command mode:
<s>
Joins the current line and the next line.
- Vi command mode:
<J>
Replace all characters between the current brace character and it's matching partner.
- Vi command mode:
<c,%>
Delete to the end of the word, as delimited by white space, and enter insert mode.
- Vi command mode:
<c,E>
Delete to the end of the word, as delimited by white space and common delimiters, and enter insert mode.
- Vi command mode:
<c,E>
Delete to the beginning of the next word, as delimited by white space, and enter insert mode.
- Vi command mode:
<c,W>
Erase the entire command line.
- Vi command mode:
<S>
,<c,c>
Replaces until given character.
- Vi command mode:
<c,t>
Replaces until given character.
- Vi command mode:
<c,T>
Deletes until given character.
- Vi command mode:
<c,f>
Replaces until given character.
- Vi command mode:
<c,F>
Replace the characters from the cursor position to the end of the line.
- Vi command mode:
<c,$>
,<C>
Replace the current character until an escape is entered or the line is accepted.
- Vi command mode:
<r>
Replace the current word.
- Vi command mode:
<c,W>
Yank from the beginning of the buffer to the cursor.
- Vi command mode:
<y,0>
Yank from the cursor to the end of the WORD(s).
- Vi command mode:
<y,E>
Yank from the cursor to the end of the word(s).
- Vi command mode:
<y,e>
Yank character(s) to the left of the cursor.
- Vi command mode:
<y,h>
Yank the entire buffer.
- Vi command mode:
<y,y>
Yank from cursor to the start of the next WORD(s).
- Vi command mode:
<y,W>
Yank the word(s) after the cursor.
- Vi command mode:
<y,w>
Yank to/from matching brace.
- Vi command mode:
<y,%>
Yank from beginning of the WORD(s) to cursor.
- Vi command mode:
<y,B>
Yank the word(s) before the cursor.
- Vi command mode:
<y,b>
Yank character(s) under and to the right of the cursor.
- Vi command mode:
<y,l>
,<y,Spacebar>
Yank from the cursor to the end of the buffer.
- Vi command mode:
<y,$>
Yank from the first non-whitespace character to the cursor.
- Vi command mode:
<y,^>
Add the most recently killed text to the input.
- Emacs mode:
Ctrl+y
Yank the last argument from the previous history line. With an argument, the first time it's invoked, behaves just like YankNthArg. If invoked multiple times, instead it iterates through history and arg sets the direction (negative reverses the direction.)
- Windows mode:
Alt+.
- Emacs mode:
Alt+.
,Alt+_
,Escape,.
,Escape,_
Yank the first argument (after the command) from the previous history line. With an argument, yank the nth argument (starting from 0), if the argument is negative, start from the last argument.
- Emacs mode:
Ctrl+Alt+y
,Escape,Ctrl+y
If the previous operation was Yank or YankPop, replace the previously yanked text with the next killed text from the kill-ring.
- Emacs mode:
Alt+y
,Escape,y
Attempt to perform completion on the text surrounding the cursor. If there are multiple possible completions, the longest unambiguous prefix is used for completion. If trying to complete the longest unambiguous completion, a list of possible completions is displayed.
- Emacs mode:
Tab
Attempt to perform completion on the text surrounding the cursor. If there are multiple possible completions, the longest unambiguous prefix is used for completion. If trying to complete the longest unambiguous completion, a list of possible completions is displayed.
- Windows mode:
Ctrl+@
,Ctrl+Spacebar
- Emacs mode:
Ctrl+Spacebar
Display the list of possible completions.
- Emacs mode:
Alt+=
- Vi insert mode:
Ctrl+Spacebar
- Vi command mode:
<Ctrl+Spacebar>
Attempt to complete the text surrounding the cursor with the next available completion.
- Windows mode:
Tab
- Vi command mode:
<Tab>
Attempt to complete the text surrounding the cursor with the previous available completion.
- Windows mode:
Shift+Tab
- Vi command mode:
<Shift+Tab>
Ends the current edit group, if needed, and invokes TabCompleteNext.
- Vi insert mode:
Tab
Ends the current edit group, if needed, and invokes TabCompletePrevious.
- Vi insert mode:
Shift+Tab
Move the cursor one character to the left. This may move the cursor to the previous line of multi-line input.
- Windows mode:
LeftArrow
- Emacs mode:
LeftArrow
,Ctrl+b
Move the cursor back to the start of the current word, or if between words, the start of the previous word. Word boundaries are defined by a configurable set of characters.
- Windows mode:
Ctrl+LeftArrow
- Emacs mode:
Alt+b
,Escape,b
- Vi insert mode:
Ctrl+LeftArrow
- Vi command mode:
<Ctrl+LeftArrow>
The characters that define word boundaries are configured in the WordDelimiters property of the PSConsoleReadLineOptions object. To view or change the WordDelimiters property, see Get-PSReadLineOption and Set-PSReadLineOption.
If the input has multiple lines, move to the start of the current line, or if already at the start of the line, move to the start of the input. If the input has a single line, move to the start of the input.
- Windows mode:
Home
- Emacs mode:
Home
,Ctrl+a
- Vi insert mode:
Home
- Vi command mode:
<Home>
If the input has multiple lines, move to the end of the current line, or if already at the end of the line, move to the end of the input. If the input has a single line, move to the end of the input.
- Windows mode:
End
- Emacs mode:
End
,Ctrl+e
- Vi insert mode:
End
Move the cursor one character to the right. This may move the cursor to the next line of multi-line input.
- Windows mode:
RightArrow
- Emacs mode:
RightArrow
,Ctrl+f
Move the cursor forward to the end of the current word, or if between words, to the end of the next word. Word boundaries are defined by a configurable set of characters.
- Emacs mode:
Alt+f
,Escape,f
The characters that define word boundaries are configured in the WordDelimiters property of the PSConsoleReadLineOptions object. To view or change the WordDelimiters property, see Get-PSReadLineOption and Set-PSReadLineOption.
Go to the matching brace, parenthesis, or square bracket.
- Windows mode:
Ctrl+]
- Vi insert mode:
Ctrl+]
- Vi command mode:
<Ctrl+]>
Move to the column indicated by arg.
- Vi command mode:
<|>
Move the cursor to the first non-blank character in the line.
- Vi command mode:
<^>
,<_>
Move the cursor to the end of the input.
- Vi command mode:
<End>
,<$>
Go to the first line in a multiline command.
- Vi command mode:
<g,g>
Go to the last line in a multiline command.
- Vi command mode:
<G>
Move the cursor to the next line.
- Function is unbound.
Move the cursor forward to the start of the next word. Word boundaries are defined by a configurable set of characters.
- Windows mode:
Ctrl+RightArrow
- Vi insert mode:
Ctrl+RightArrow
- Vi command mode:
<Ctrl+RightArrow>
The characters that define word boundaries are configured in the WordDelimiters property of the PSConsoleReadLineOptions object. To view or change the WordDelimiters property, see Get-PSReadLineOption and Set-PSReadLineOption.
Move the cursor forward to the end of the current word, or if between words, to the end of the next word. Word boundaries are defined by a configurable set of characters.
- Vi command mode:
<e>
The characters that define word boundaries are configured in the WordDelimiters property of the PSConsoleReadLineOptions object. To view or change the WordDelimiters property, see Get-PSReadLineOption and Set-PSReadLineOption.
Move the cursor to the previous line.
- Function is unbound.
Move the cursor back to the start of the current word, or if between words, the start of the previous word. Word boundaries are defined by PowerShell tokens.
- Function is unbound.
Move the cursor forward to the start of the next word. Word boundaries are defined by PowerShell tokens.
- Function is unbound.
Move the cursor forward to the end of the current word, or if between words, to the end of the next word. Word boundaries are defined by PowerShell tokens.
- Function is unbound.
Move the cursor one character to the left in the Vi edit mode. This may move the cursor to the previous line of multi-line input.
- Vi insert mode:
LeftArrow
- Vi command mode:
<LeftArrow>
,<Backspace>
,<h>
Move the cursor back to the start of the current word, or if between words, the start of the previous word. Word boundaries are defined by a configurable set of characters.
- Vi command mode:
<b>
The characters that define word boundaries are configured in the WordDelimiters property of the PSConsoleReadLineOptions object. To view or change the WordDelimiters property, see Get-PSReadLineOption and Set-PSReadLineOption.
Move the cursor to the end this word, as delimited by white space.
- Vi command mode:
<E>
Moves to the end of the previous word, using only whitespace as a word delimiter.
- Function is unbound.
Move the cursor one character to the right in the Vi edit mode. This may move the cursor to the next line of multi-line input.
- Vi insert mode:
RightArrow
- Vi command mode:
<RightArrow>
,<Spacebar>
,<l>
Similar to GotoBrace, but is character based instead of token based.
- Vi command mode:
<%>
Moves to the next word, using only whitespace as a word delimiter.
- Vi command mode:
<W>
Move the cursor forward to the start of the next word. Word boundaries are defined by a configurable set of characters.
- Vi command mode:
<w>
The characters that define word boundaries are configured in the WordDelimiters property of the PSConsoleReadLineOptions object. To view or change the WordDelimiters property, see Get-PSReadLineOption and Set-PSReadLineOption.
Move to the first item in the history.
- Emacs mode:
Alt+<
Clears history in PSReadLine. This doesn't affect PowerShell history.
- Windows mode:
Alt+F7
Move to the last item (the current input) in the history.
- Emacs mode:
Alt+>
Perform an incremental forward search through history.
- Windows mode:
Ctrl+s
- Emacs mode:
Ctrl+s
- Vi insert mode:
Ctrl+s
- Vi command mode:
<Ctrl+s>
Replace the current input with the 'previous' item from PSReadLine history that matches the characters between the start and the input and the cursor.
- Windows mode:
F8
Replace the current input with the 'next' item from PSReadLine history that matches the characters between the start and the input and the cursor.
- Windows mode:
Shift+F8
Replace the current input with the 'next' item from PSReadLine history.
- Windows mode:
DownArrow
- Emacs mode:
DownArrow
,Ctrl+n
- Vi insert mode:
DownArrow
- Vi command mode:
<DownArrow>
,<j>
,<+>
Replace the current input with the 'previous' item from PSReadLine history.
- Windows mode:
UpArrow
- Emacs mode:
UpArrow
,Ctrl+p
- Vi insert mode:
UpArrow
- Vi command mode:
<UpArrow>
,<k>
,<->
Perform an incremental backward search through history.
- Windows mode:
Ctrl+r
- Emacs mode:
Ctrl+r
- Vi insert mode:
Ctrl+r
- Vi command mode:
<Ctrl+r>
Prompts for a search string and initiates search upon AcceptLine.
- Vi command mode:
</>
Start interactive screen capture - up/down arrows select lines, enter copies selected text to clipboard as text and HTML.
- Function is unbound.
Clear the screen and draw the current line at the top of the screen.
- Windows mode:
Ctrl+l
- Emacs mode:
Ctrl+l
- Vi insert mode:
Ctrl+l
- Vi command mode:
<Ctrl+l>
Start a new digit argument to pass to other functions. You can use this as a
multiplier for the next function that's invoked by a keypress. For example,
pressing <Alt+1>
<Alt+0>
sets the digit-argument value to 10. Then,
pressing the #
key sends 10 #
characters (##########
) to the input line.
Similarly, you can use this with other operations, like <Delete>
or
Left-Arrow
.
- Windows mode:
Alt+0
,Alt+1
,Alt+2
,Alt+3
,Alt+4
,Alt+5
,Alt+6
,Alt+7
,Alt+8
,Alt+9
,Alt+-
- Emacs mode:
Alt+0
,Alt+1
,Alt+2
,Alt+3
,Alt+4
,Alt+5
,Alt+6
,Alt+7
,Alt+8
,Alt+9
,Alt+-
- Vi command mode:
<0>
,<1>
,<2>
,<3>
,<4>
,<5>
,<6>
,<7>
,<8>
,<9>
Erases the current prompt and calls the prompt function to redisplay the prompt. Useful for custom key handlers that change state. For example, change the current directory.
- Function is unbound.
Scroll the display down one screen.
- Windows mode:
PageDown
- Emacs mode:
PageDown
Scroll the display down one line.
- Windows mode:
Ctrl+PageDown
- Emacs mode:
Ctrl+PageDown
Scroll the display to the cursor.
- Emacs mode:
Ctrl+End
Scroll the display to the top.
- Emacs mode:
Ctrl+Home
Scroll the display up one screen.
- Windows mode:
PageUp
- Emacs mode:
PageUp
Scroll the display up one line.
- Windows mode:
Ctrl+PageUp
- Emacs mode:
Ctrl+PageUp
Provides a view of full cmdlet help. When the cursor is at the end of a fully
expanded parameter, hitting the <F1>
key positions the display of help at the
location of that parameter.
The help is displayed on an alternate screen buffer using a Pager from Microsoft.PowerShell.Pager. When you exit the pager you are returned to the original cursor position on the original screen. This pager only works in modern terminal applications such as Windows Terminal.
- Windows mode:
F1
- Emacs mode:
F1
- Vi insert mode:
F1
- Vi command mode:
<F1>
Show all bound keys.
- Windows mode:
Ctrl+Alt+?
- Emacs mode:
Ctrl+Alt+?
- Vi insert mode:
Ctrl+Alt+?
Provides dynamic help for parameters by showing it below the current command
line like MenuComplete
. The cursor must be at the end of the fully expanded
parameter name when you press the <Alt+h>
key.
- Windows mode:
Alt+h
- Emacs mode:
Alt+h
- Vi insert mode:
Alt+h
- Vi command mode:
<Alt+h>
Switch the current operating mode from Vi-Insert to Vi-Command.
- Vi insert mode:
Escape
Start a new digit argument to pass to other functions while in one of vi's chords.
- Function is unbound.
Edit the command line in a text editor specified by $env:EDITOR
or
$env:VISUAL
.
- Emacs mode:
Ctrl+x,Ctrl+e
- Vi command mode:
<v>
Exits the shell.
- Function is unbound.
Switch to Insert mode.
- Vi command mode:
<i>
Read a key and tell me what the key is bound to.
- Windows mode:
Alt+?
- Emacs mode:
Alt+?
Accept the next word of the inline or selected suggestion
- Function is unbound.
When using InlineView
as the view style for prediction, accept the current
inline suggestion.
- Function is unbound.
When using ListView
as the view style for prediction, navigate to the next
suggestion in the list.
- Function is unbound.
When using ListView
as the view style for prediction, navigate to the
previous suggestion in the list.
- Function is unbound.
Show the tooltip of the currently selected list item in the full view.
- Windows mode:
F4
- Emacs mode:
F4
- Vi insert mode:
F4
Switch the view style for prediction between InlineView
and ListView
.
- Windows mode:
F2
- Emacs mode:
F2
- Vi insert mode:
F2
Read a character and search forward for the next occurrence of that character. If an argument is specified, search forward (or backward if negative) for the nth occurrence.
- Windows mode:
F3
- Emacs mode:
Ctrl+]
- Vi insert mode:
F3
- Vi command mode:
<F3>
Read a character and search backward for the next occurrence of that character. If an argument is specified, search backward (or forward if negative) for the nth occurrence.
- Windows mode:
Shift+F3
- Emacs mode:
Ctrl+Alt+]
- Vi insert mode:
Shift+F3
- Vi command mode:
<Shift+F3>
Repeat the last recorded character search.
- Vi command mode:
<;>
Repeat the last recorded character search, but in the opposite direction.
- Vi command mode:
<,>
Repeat the last search in the same direction as before.
- Vi command mode:
<n>
Repeat the last search in the same direction as before.
- Vi command mode:
<N>
Read the next character and then find it, going forward.
- Vi command mode:
<f>
Read the next character and then find it, going backward.
- Vi command mode:
<F>
Read the next character and then find it, going backward, and then back off a character.
- Vi command mode:
<T>
Read the next character and then find it, going forward, and then back off a character.
- Vi command mode:
<t>
Prompts for a search string and initiates search upon AcceptLine.
- Vi command mode:
<?>
The cursor is placed at the location of the mark and the mark is moved to the location of the cursor.
- Emacs mode:
Ctrl+x,Ctrl+x
Select the entire line.
- Windows mode:
Ctrl+a
Adjust the current selection to include the previous character.
- Windows mode:
Shift+LeftArrow
- Emacs mode:
Shift+LeftArrow
Adjust the current selection to include from the cursor to the start of the line.
- Windows mode:
Shift+Home
- Emacs mode:
Shift+Home
Adjust the current selection to include the previous word.
- Windows mode:
Shift+Ctrl+LeftArrow
- Emacs mode:
Alt+B
Make visual selection of the command arguments. Selection of arguments is scoped within a script block. Based on the cursor position, it searches from the innermost script block to the outmost script block, and stops when it finds any arguments in a script block scope.
This function honors DigitArgument. It treats the positive or negative argument values as the forward or backward offsets from the currently selected argument, or from the current cursor position when no argument is selected.
- Windows mode:
Alt+a
- Emacs mode:
Alt+a
Adjust the current selection to include the next character.
- Windows mode:
Shift+RightArrow
- Emacs mode:
Shift+RightArrow
Adjust the current selection to include the next word using ForwardWord.
- Emacs mode:
Alt+F
Adjust the current selection to include from the cursor to the end of the line.
- Windows mode:
Shift+End
- Emacs mode:
Shift+End
Adjust the current selection to include the next word.
- Windows mode:
Shift+Ctrl+RightArrow
Adjust the current selection to include the previous word using ShellBackwardWord.
- Function is unbound.
Adjust the current selection to include the next word using ShellForwardWord.
- Function is unbound.
Adjust the current selection to include the next word using ShellNextWord.
- Function is unbound.
Mark the current location of the cursor for use in a subsequent editing command.
- Emacs mode:
Ctrl+@
The following functions are public in Microsoft.PowerShell.PSConsoleReadLine, but can't be directly bound to a key. Most are useful in custom key bindings.
void AddToHistory(string command)
Add a command line to history without executing it.
void ClearKillRing()
Clear the kill-ring. This is mostly used for testing.
void Delete(int start, int length)
Delete length characters from start. This operation supports undo/redo.
void Ding()
Perform the Ding action based on the user's preference.
void GetBufferState([ref] string input, [ref] int cursor)
void GetBufferState([ref] Ast ast, [ref] Token[] tokens,
[ref] ParseError[] parseErrors, [ref] int cursor)
These two functions retrieve useful information about the current state of the input buffer. The first is more commonly used for simple cases. The second is used if your binding is doing something more advanced with the Ast.
IEnumerable[Microsoft.PowerShell.KeyHandler]
GetKeyHandlers(bool includeBound, bool includeUnbound)
IEnumerable[Microsoft.PowerShell.KeyHandler]
GetKeyHandlers(string[] Chord)
These two functions are used by Get-PSReadLineKeyHandler
. The first is used
to get all key bindings. The second is used to get specific key bindings.
Microsoft.PowerShell.PSConsoleReadLineOptions GetOptions()
This function is used by Get-PSReadLineOption and probably isn't too useful in a custom key binding.
void GetSelectionState([ref] int start, [ref] int length)
If there's no selection on the command line, the function returns -1 in both start and length. If there's a selection on the command line, the start and length of the selection are returned.
void Insert(char c)
void Insert(string s)
Insert a character or string at the cursor. This operation supports undo/redo.
string ReadLine(runspace remoteRunspace,
System.Management.Automation.EngineIntrinsics engineIntrinsics)
This is the main entry point to PSReadLine. It doesn't support recursion, so isn't useful in a custom key binding.
void RemoveKeyHandler(string[] key)
This function is used by Remove-PSReadLineKeyHandler and probably isn't too useful in a custom key binding.
void Replace(int start, int length, string replacement)
Replace some input. This operation supports undo/redo. This is preferred over Delete followed by Insert because it's treated as a single action for undo.
void SetCursorPosition(int cursor)
Move the cursor to the given offset. Cursor movement isn't tracked for undo.
void SetOptions(Microsoft.PowerShell.SetPSReadLineOption options)
This function is a helper method used by the cmdlet Set-PSReadLineOption
, but
might be useful to a custom key binding that wants to temporarily change a
setting.
bool TryGetArgAsInt(System.Object arg, [ref] int numericArg,
int defaultNumericArg)
This helper method is used for custom bindings that honor DigitArgument. A typical call looks like
[int]$numericArg = 0
[Microsoft.PowerShell.PSConsoleReadLine]::TryGetArgAsInt($arg,
[ref]$numericArg, 1)
Behavior of the OnIdle event
When PSReadLine is in use, the OnIdle event is fired when
ReadKey()
times out (no typing in 300ms). The event could be signaled while the user is in the middle of editing a command line, for example, the user is reading help to decide which parameter to use.Beginning in PSReadLine 2.2.0-beta4, OnIdle behavior changed to signal the event only if there's a
ReadKey()
timeout and the current editing buffer is empty.
PowerShell feedback
PowerShell is an open source project. Select a link to provide feedback: