PowerShell#
PowerShell’s interactive editor is provided by PSReadLine, a module that ships with PowerShell 5.1+ and pwsh (PowerShell 7+). PSReadLine defaults to an emacs-style keymap on Linux / macOS and to a Windows-style keymap on Windows; both share the same underlying widgets.
Get-PSReadLineKeyHandler lists every binding;
Set-PSReadLineKeyHandler sets one;
Set-PSReadLineOption -EditMode Emacs (or -EditMode Vi /
-EditMode Windows) switches the keymap. Persist customizations
in $PROFILE.
For PowerShell scripting (pipeline objects, Get- / Set- /
New- cmdlets, profile loading), see the language pages.
Cursor Movement#
Key |
Action |
|---|---|
|
move to start of line |
|
move to end of line |
|
move back one character |
|
move forward one character |
|
move back one word |
|
move forward one word |
Editing#
Key |
Action |
|---|---|
|
delete character under cursor |
|
delete character before cursor |
|
delete word forward |
|
delete word backward |
|
delete word backward (alphanumeric-aware) |
|
kill to end of line |
|
kill whole line |
|
yank (paste) last killed text |
|
cycle through previous yanks after Ctrl-y |
|
transpose character with previous |
|
transpose word with previous |
|
uppercase word from cursor |
|
lowercase word from cursor |
|
capitalize word from cursor |
|
undo last edit |
|
redo |
History#
PSReadLine supports prefix search (Up / Down) plus an Fzf-style
incremental search (Ctrl-r). The session history is in
$PROFILE-controlled paths; Get-History is the cmdlet
form.
Key |
Action |
|---|---|
|
previous history (prefix-search-backward) |
|
next history (prefix-search-forward) |
|
reverse incremental search |
|
forward incremental search |
|
insert last argument of previous command |
|
print history |
|
re-run history entry |
|
clear current-session history |
Process Control#
Key |
Action |
|---|---|
|
cancel current line / send Ctrl-C to running command |
|
send EOF; exit on empty line |
|
clear screen (keeps current line) |
|
hard interrupt (Windows; closes pipeline) |
|
same as Ctrl-Break on some terminals |
Completion#
Tab cycles through inline completions; Ctrl-Space opens the
menu pager (PSReadLine MenuComplete). Inside the pager use
arrows + Enter.
Key |
Action |
|---|---|
|
complete / cycle next match |
|
cycle previous match |
|
open menu completion pager ( |
|
close completion pager |
|
accept selection |
|
complete and display all matches |
|
same as Ctrl-Space on terminals that map it |
PSReadLine Specials#
PSReadLine-only widgets and bindings.
Key |
Action |
|---|---|
|
show help for command at cursor ( |
|
show parameter help ( |
|
context-sensitive help for token at cursor |
|
toggle between |
|
search-by-prefix backward / forward through history |
|
select whole argument under cursor ( |
|
copy selected text |
|
paste from clipboard |
Vi Mode#
Enable with Set-PSReadLineOption -EditMode Vi. Standard
Vim keymap inside the line editor.
Key |
Action |
|---|---|
|
enter command mode |
|
insert / append at cursor / line start / line end |
|
move to start / first non-blank / end of line |
|
word forward / back / end |
|
find next / previous character |
|
delete character under cursor |
|
delete word / to end / whole line |
|
change word / to end / whole line |
|
yank word / to end / whole line |
|
paste after / before |
|
undo |
|
redo |
|
open current line in |
|
previous / next history (command mode) |
|
history search backward |
Config and Discovery#
Command |
Action |
|---|---|
|
list every binding |
|
list only bound keys |
|
list unbound widgets |
|
bind a chord to a widget |
|
remove a binding |
|
switch to emacs keymap |
|
switch to vi keymap |
|
inline suggestions from history + plugins |
|
list-style suggestion view |
|
print every PSReadLine option |
|
path to current-user profile (persist customizations here) |
|
download help so |