Repository navigation
Description
Prerequisites
- Write a descriptive title.
Description of the new feature/enhancement
As a PowerShell user editing commands interactively,
I want the default PSReadLine key bindings to match the bindings used by Linux/Emacs-style shells (bash, zsh, fish) out of the box,
so that muscle memory transfers across platforms,
common editing tasks take fewer keystrokes,
and new users get an efficient out-of-box editing experience
without having to copy key-binding snippets into every $PROFILE.
This is the same request as #1839, which was closed without a change to the defaults.
I've searched both PowerShell/PowerShell and PowerShell/PSReadLine and haven't found an open duplicate.
(This issue was initially filed at #28459 and is moved here,
since the default bindings live in this repository.)
I am politely asking that the shipped default bindings be changed to the following
(the same snippet many users already carry in their profiles):
Set-PSReadlineKeyHandler -Key Ctrl+a -Function BeginningOfLine
Set-PSReadlineKeyHandler -Key Ctrl+e -Function EndOfLine
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadLineKeyHandler -Key UpArrow -ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchBackward()
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
}
Set-PSReadLineKeyHandler -Key DownArrow -ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchForward()
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
}Current vs. proposed bindings
| Key | Current default (Windows edit mode) | Current default (Emacs edit mode) | Proposed |
|---|---|---|---|
Ctrl+A |
SelectAll |
BeginningOfLine |
BeginningOfLine |
Ctrl+E |
(unbound) | EndOfLine |
EndOfLine |
Tab |
TabCompleteNext (cycles inline) |
Complete (bash-style) |
MenuComplete |
UpArrow |
PreviousHistory |
PreviousHistory |
HistorySearchBackward + cursor to end of line |
DownArrow |
NextHistory |
NextHistory |
HistorySearchForward + cursor to end of line |
Home/End remain bound to BeginningOfLine/EndOfLine; this change adds the Ctrl-based bindings, it does not remove Home/End.
Detailed usability improvements vs. the current bindings
1) Ctrl+A → BeginningOfLine, Ctrl+E → EndOfLine
What we gain compared to the current Windows edit mode:
- It matches readline/Emacs/fish muscle memory. bash and zsh (in their default emacs editing mode) and fish all bind
Ctrl+A/Ctrl+Eto beginning/end of line. Anyone arriving from those shells — or from Emacs — currently has to re-learn or re-bind these keys on Windows. - The Windows edit mode is the outlier today. PSReadLine's own Emacs edit mode already binds
Ctrl+A/Ctrl+Eexactly this way, so the proposal makes the edit modes consistent instead of making Windows users special-case their muscle memory per edit mode. Ctrl+Eis unbound in the Windows edit mode today. There is currently no control-key binding for "jump to end of line" at all. Filling that gap costs nothing and removes a real inconsistency between the two edit modes.- Home-row editing.
HomeandEndare grouped withInsert/Delete/PageUp/PageDownon full keyboards and are often only reachable viaFnon compact laptop keyboards. In a REPL you constantly navigate to the end of the command line to append a flag or a path, and back to the start to change the command itself.Ctrl+A/Ctrl+Ekeep both hands on the home row and are reachable without looking down. SelectAllonCtrl+Ais low-value in a REPL. Selecting the entire single command line and replacing it on the next keystroke is a niche workflow; the common "select the current command" case is still served byShift+End(SelectLine). Removing the overloaded meaning fromCtrl+Aalso removes the surprising "pressCtrl+A, type, and wipe the line" gesture.- Cross-platform consistency. One hand position across Windows, Linux and macOS, and across edit modes; fewer edit-mode-specific docs to maintain.
2) Tab → MenuComplete
What we gain compared to TabCompleteNext (the Windows default):
- From guessing-and-cycling to browsing-and-picking. Today, each
Tabreplaces the text with the next candidate, invisibly. With a few candidates that is tolerable; with dozens or hundreds (file paths, module names, parameter values such as Azure resource names) it degenerates into blind cycling — no overview of the candidate set, no memory of where you are in the list, easy to overshoot the item you wanted, andShift+Tabgymnastics to backtrack. - The full candidate set is shown at a glance.
MenuCompleteopens an interactive menu of all matches: arrow keys /PageUp/PageDown/Tabmove between items, and it doubles as lightweight documentation (e.g.git switch <Tab>shows your branches, a cmdlet parameter shows the allowed values). - You can refine the result. Typing more characters while the menu is open filters the matches live, and
Backspacewidens the filter again — so narrowing from hundreds of matches to a handful takes a couple of keystrokes instead of a full cycle. - Escape cancels losslessly.
Escape/Ctrl+Gbacks out of the menu and restores your original input text, so experimenting with completion is risk-free. - Zero cost when the answer is unambiguous. With exactly one match,
MenuCompleteinserts it immediately without opening a menu (verified inCompleteImpl); with no matches it simply does nothing. The only behavior change is when there are multiple matches to choose from — which is exactly when the extra UI pays for itself. - It is consistent with the direction PSReadLine is already taking.
MenuCompletealready exists and is already bound toCtrl+Space(Windows) /Ctrl+@; this request just makes Tab reach it. The Emacs edit mode keeps its bash-styleComplete, which maintainers have indicated is superior for its context — so this could be scoped to the Windows edit mode if preferred. - Aligns with maintainer feedback in Enable Gitter #1839. In PSReadLine Enable Gitter #1839,
@lzybkragreed the history/completion defaults deserved reconsideration and was open to changing the Windows default, and@SeeminglySciencesketched the ideal menu experience. The currentMenuCompleteimplements essentially that sketch: single result completes inline, ambiguous results open a navigable menu, typed characters filter,Escapecancels,Tabadvances.
Trade-off to call out honestly: this is the most visible of the four changes. Users who have built TabCompleteNext muscle memory for cycling one candidate per press would need an adjustment period and, if they prefer the old behavior, a one-line profile change. It mirrors the (very popular) menu-complete settings in zsh/fish more than stock bash, and it is the change most worth debating — I am not asking to remove TabCompleteNext, only to change which function Tab invokes by default.
3) UpArrow/DownArrow → prefix-based history search, cursor moved to end
What we gain compared to PreviousHistory/NextHistory:
- Search instead of paging. Today,
Upcycles through all history entries regardless of what you have typed. With a long history (which accumulates fast, and PSReadLine includes entries from previous sessions) you may page through dozens of unrelated commands. With the proposed binding, typinggit sand pressingUpjumps straight to the most recentgit s…command, and repeated presses walk back through only the matching entries. This is the behaviorfishships by default, and the behavior of readline'shistory-search-backward/history-search-forward, a ubiquitous opt-in in bash/zsh dotfiles. - The cursor lands at the end of the line, like bash/fish/Emacs and like
gitusers expect. With the current default (-HistorySearchCursorMovesToEnddefaults to$false), recalling a command withHistorySearchBackwardleaves the cursor right after the typed prefix — i.e. inside the recalled line. In practice you almost always want to edit the tail (change a flag, add a path, swap an argument), which today means an extra, unnecessaryEndkeypress after every recall. Wrapping the calls in theScriptBlockabove gives the desired behavior regardless of the user's-HistorySearchCursorMovesToEndsetting. (Alternatively, the same effect could be achieved by bindingUp/DownArrowtoHistorySearchBackward/HistorySearchForwardand changing the default ofHistorySearchCursorMovesToEndto$true— whichever the maintainers prefer.) DownArrowmirrors this, walking forward through matches back toward your in-progress line — somethingNextHistorycannot express when combined with a prefix.- No regression on an empty line. With an empty prefix,
HistorySearchBackwardmatches every entry — i.e. it behaves likePreviousHistory(it merely skips entries from other sessions, which is arguably the desirable behavior here). - No regression in multi-line buffers.
HistorySearchdetectsLineIsMultiLine()and moves within the multi-line buffer (MoveToLine) instead of jumping into history — so editing a multi-line command still works as you would expect, the same way zsh'sup-line-or-historybehaves. - Prefix emphasis. PSReadLine already highlights the searched prefix in the buffer during the search, which makes it visually obvious why a given entry was selected.
- In-progress line is preserved and recoverable.
HistorySearchBackwardsaves the current line before searching, so holdingDownArrowuntil the end brings you back to exactly what you were typing. - Net keystroke reduction in the extremely common "re-run the last
kubectl/git/sshcommand with a tweak" workflow: two keystrokes (type prefix, press Up) instead of N paging presses, with fewer chances of accepting the wrong entry.
Consistency payoff across all four changes
- One set of conventions across Windows and non-Windows, and across Windows and Emacs edit modes.
- Fewer "why doesn't PowerShell feel like my shell?" surprises for new users.
- Profile snippets shrink: less copy-paste boilerplate in every shared profile and onboarding doc.
- None of the existing functions (
SelectAll,TabCompleteNext,PreviousHistory,NextHistory) are removed or renamed — existing user overrides andSet-PSReadLineOption -EditModeworkflows keep working unchanged.
Proposed technical implementation details (optional)
- The defaults live in
SetDefaultWindowsBindings/SetDefaultEmacsBindingsinKeyBindings.cs;
the Windows edit mode is the out-of-box default on Windows, Emacs on other platforms. Tab(MenuComplete→CompleteImpl(true)): with exactly one match the completion is inserted inline;
with no matches nothing happens; with multiple matches an interactive menu is shown
(arrows /PageUp/PageDown/Tabnavigate, typed characters filter viaFilterCompletions,
Backspacewidens the filter,Escape/Ctrl+Gcancels withundorestoring the original line).Up/DownArrow(HistorySearchBackward/Forward):HistorySearchuses the text before the cursor as the prefix
(_searchHistoryPrefix), matches history entries by prefix,
and falls back toMoveToLinefor multi-line buffers.
The proposedScriptBlockadditionally callsEndOfLine()so the cursor lands at the end of the recalled line,
compensating forDefaultHistorySearchCursorMovesToEnd = false.
An alternative implementation is to bindUp/DownArrowdirectly toHistorySearchBackward/HistorySearchForward
and flipHistorySearchCursorMovesToEnd's default to$true.
Open questions for maintainers (happy to adapt the request):
- Scope of
Tab→MenuComplete: all edit modes, or only the Windows edit mode (keeping Emacs' bash-styleComplete, as suggested in Enable Gitter #1839)? - Scope of
Up/DownArrow: all edit modes, or only Windows? (Both edit modes currently usePreviousHistory/NextHistory.) - Implementation of cursor-at-end: script-block bindings as written, or binding
Up/DownArrowtoHistorySearchBackward/Forwardand flippingHistorySearchCursorMovesToEnd's default to$true? - Discoverability/signposting: should this ship with a release-notes entry and updated
about_PSReadLine_Functions/about_PSReadLinedocs, given it is a visible behavioral change to an out-of-box experience?
Thanks for your time and for maintaining PSReadLine — and for considering this.
Activity
soredake commentedon Nov 19, 2026
Moved to PowerShell/PSReadLine issue 5240, the repository where the default bindings live.