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

Ctrl-a / Home

move to start of line

Ctrl-e / End

move to end of line

Ctrl-b / Left

move back one character

Ctrl-f / Right

move forward one character

Alt-b / Ctrl-Left

move back one word

Alt-f / Ctrl-Right

move forward one word

Editing#

Key

Action

Ctrl-d / Delete

delete character under cursor

Ctrl-h / Backspace

delete character before cursor

Alt-d

delete word forward

Ctrl-w

delete word backward

Alt-Backspace

delete word backward (alphanumeric-aware)

Ctrl-k

kill to end of line

Ctrl-u

kill whole line

Ctrl-y

yank (paste) last killed text

Alt-y

cycle through previous yanks after Ctrl-y

Ctrl-t

transpose character with previous

Alt-t

transpose word with previous

Alt-u

uppercase word from cursor

Alt-l

lowercase word from cursor

Alt-c

capitalize word from cursor

Ctrl-_

undo last edit

Ctrl-y (Windows mode)

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

Up / Ctrl-p

previous history (prefix-search-backward)

Down / Ctrl-n

next history (prefix-search-forward)

Ctrl-r

reverse incremental search

Ctrl-s

forward incremental search

Alt-.

insert last argument of previous command

Get-History

print history

Invoke-History <id>

re-run history entry

Clear-History

clear current-session history

Process Control#

Key

Action

Ctrl-c

cancel current line / send Ctrl-C to running command

Ctrl-d

send EOF; exit on empty line

Ctrl-l

clear screen (keeps current line)

Ctrl-Break

hard interrupt (Windows; closes pipeline)

Ctrl-Pause

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

Tab

complete / cycle next match

Shift-Tab

cycle previous match

Ctrl-Space

open menu completion pager (MenuComplete)

Esc

close completion pager

Enter

accept selection

Alt-=

complete and display all matches

Ctrl-@

same as Ctrl-Space on terminals that map it

PSReadLine Specials#

PSReadLine-only widgets and bindings.

Key

Action

Alt-h

show help for command at cursor (ShowCommandHelp)

Alt-?

show parameter help (WhatIsKey describes a binding)

F1

context-sensitive help for token at cursor

F2

toggle between HistoryAndPlugin and History prediction sources

F8 / Shift-F8

search-by-prefix backward / forward through history

Alt-a

select whole argument under cursor (SelectCommandArgument)

Alt-Shift-c

copy selected text

Ctrl-Shift-v

paste from clipboard

Vi Mode#

Enable with Set-PSReadLineOption -EditMode Vi. Standard Vim keymap inside the line editor.

Key

Action

Esc

enter command mode

i / a / I / A

insert / append at cursor / line start / line end

0 / ^ / $

move to start / first non-blank / end of line

w / b / e

word forward / back / end

f<c> / F<c>

find next / previous character

x

delete character under cursor

dw / d$ / dd

delete word / to end / whole line

cw / c$ / cc

change word / to end / whole line

yw / y$ / yy

yank word / to end / whole line

p / P

paste after / before

u

undo

Ctrl-r

redo

v

open current line in $env:EDITOR

k / j

previous / next history (command mode)

/<pat>

history search backward

Config and Discovery#

Command

Action

Get-PSReadLineKeyHandler

list every binding

Get-PSReadLineKeyHandler -Bound

list only bound keys

Get-PSReadLineKeyHandler -Unbound

list unbound widgets

Set-PSReadLineKeyHandler -Chord 'Ctrl+x' -Function KillRegion

bind a chord to a widget

Remove-PSReadLineKeyHandler -Chord 'Ctrl+x'

remove a binding

Set-PSReadLineOption -EditMode Emacs

switch to emacs keymap

Set-PSReadLineOption -EditMode Vi

switch to vi keymap

Set-PSReadLineOption -PredictionSource HistoryAndPlugin

inline suggestions from history + plugins

Set-PSReadLineOption -PredictionViewStyle ListView

list-style suggestion view

Get-PSReadLineOption

print every PSReadLine option

$PROFILE

path to current-user profile (persist customizations here)

Update-Help

download help so Alt-h / F1 work