Skip to content

Feature Request: Create a EndOfLineOrAcceptSuggestion function for Ctrl+e binding #4929

Description

Prerequisites

  • Write a descriptive title.

Description of the new feature/enhancement

Many users, especially those with Emacs muscle memory, expect Ctrl+e to move the cursor to the end of the line (the EndOfLine function).

With the introduction of predictions, many of these same users want to bind Ctrl+e to also accept the full inline suggestion, similar to how RightArrow works.

The current, discoverable way to do this is:

Set-PSReadLineKeyHandler -Chord 'Ctrl+e' -Function AcceptSuggestion

However, this binding completely overrides the original EndOfLine behavior. This forces the user to choose between one function or the other, which is a poor experience.

Proposed technical implementation details (optional)

I propose adding a new, built-in PSReadLine function (e.g., EndOfLineOrAcceptSuggestion) that intelligently combines both behaviors.

The logic for this new function would be:

  1. If the cursor is not at the end of the line, perform the EndOfLine action.
  2. If the cursor is already at the end of the line, perform the AcceptSuggestion action.

This would create a "smart" key binding that "does the right thing" based on context.

Activity

  1. guy-chen-codes commented on Sep 16, 2025

    @guy-chen-codes
    Author

    This pattern already exists and is a core part of the PSReadLine user experience:

    • ForwardChar (bound to RightArrow): Moves one character forward, unless at the end of the line, then it calls AcceptSuggestion.

    • ForwardWord (bound to Alt+f): Moves one word forward, unless at the end of the line, then it calls AcceptNextSuggestionWord.

    Creating a similar function for EndOfLine would make this powerful behavior consistent and easily accessible for users who prefer Ctrl+e to accept suggestions without breaking their typing flow to reach for the arrow keys.

  2. guy-chen-codes commented on Sep 16, 2025

    @guy-chen-codes
    Author

    It is possible to achieve this behavior today by adding a complex ScriptBlock to a user's $profile:

    Set-PSReadLineKeyHandler -Chord "Ctrl+e" -ScriptBlock {
        param($key, $arg)
    
        $line = $null
        $cursor = $null
        [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)
    
        if ($cursor -eq $line.Length) {
            # At end of line, accept suggestion
            [Microsoft.PowerShell.PSConsoleReadLine]::AcceptSuggestion($key, $arg)
        }
        else {
            # Not at end of line, move to end
            [Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine($key, $arg)
        }
    }

    While this works, it is not discoverable and is complex for average users. Building this logic into a named, built-in function would be a significant usability improvement.

    Thank you for considering this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-EnhancementIt's a feature request.Needs-Triage 🔍It's a new issue that core contributor team needs to triage.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions