[FEATURE] Emacs/readline mark and region in the prompt input (C-Space, C-w, M-w, C-x C-x)

Status Open
Reported on v2.1.294
Maintainer reply None cached
Activity 0 comments · opened Oct 10, 2026

Problem

The prompt already supports most of the Emacs keymap that GNU Readline (set -o emacs) and zsh's ZLE (bindkey -e) provide: C-a/C-e, C-b/C-f, M-b/M-f, C-k, C-u, C-w (delete previous word), and undo with C-_. The missing part is mark and region: there is no way to set a mark, so there is no way to cut or copy an arbitrary stretch of the prompt. In readline, zle and Emacs this is basic line editing. Without it, the only way to move a phrase is to kill it word by word.

Proposal

Add mark and region commands to the prompt, with the standard names and default keys:

| Command (readline/zle name) | Default key | Behavior |
|---|---|---|
| set-mark-command | C-Space (also C-@) | Set the mark at the cursor; the region runs from the mark to the cursor |
| kill-region | C-w when a region is active | Cut the region (without a region, C-w keeps deleting the previous word, as it does today) |
| copy-region-as-kill | M-w | Copy the region |
| exchange-point-and-mark | C-x C-x | Swap cursor and mark |
| deactivate | C-g | Clear the mark |

Killed and copied text should be available to yank with C-y, and optionally go to the system clipboard via OSC 52.

Please also expose these as actions in ~/.claude/keybindings.json (for example chat:setMark, chat:killRegion, chat:copyRegion, chat:exchangePointAndMark), so users can map them to match their own setup. Today keybindings.json has no action that starts a selection, so this can't be configured from outside.

Related

  • #97985: a selection model for the prompt using Shift+arrow keys. Complementary: both need an active region in the prompt, and this one asks for the Emacs way to drive it.
  • #73942, #63823: readline/Emacs line editing. Both were closed automatically for inactivity, not declined.

Environment

Claude Code 2.1.294, terminal UI on Windows 11 (Windows Terminal, herdr) and macOS.

View original on GitHub ↗