Vim mode: Ctrl-[ dismisses AskUserQuestion prompts instead of entering normal mode

Status Fixed / completed
Reported on v2.1.228
Maintainer reply ✓ Yes — bcherny
Activity 3 comments · opened Aug 12, 2026 · closed Aug 17, 2026
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Description

With vim mode enabled, Ctrl-[ works as an Escape alias for entering normal
mode in the main prompt. Inside an AskUserQuestion selection prompt, it is
instead treated as a dismiss/cancel key, so the question is rejected and the
turn is interrupted.

For anyone with the Ctrl-[ habit this fires constantly and unintentionally —
the keypress is reflex, and the cost is a cancelled tool call plus a lost
answer.

Steps to reproduce

  1. Enable vim mode (/vim).
  2. Get Claude to ask a question via the multiple-choice question prompt.
  3. Press Ctrl-[ intending to enter normal mode.

Expected

Ctrl-[ behaves the same as it does in the main prompt — enters normal mode,
allowing j/k navigation of the options.

Actual

The question prompt is dismissed and the tool call is rejected.

Notes

Plain Escape dismissing the prompt seems reasonable; the issue is that
Ctrl-[ is bound to dismiss too, despite vim mode having claimed it as a
normal-mode trigger everywhere else. Either vim mode should own Ctrl-[
inside these prompts, or the two keys should be unbound from each other there.

Environment

  • Claude Code 2.1.228, vim mode enabled
  • Linux

View original on GitHub ↗

3 Comments

bcherny collaborator · 2 months ago

Reproduced on v2.1.233 (macOS, tmux) in the sense that the key does dismiss the prompt.

Steps:

  1. Enable vim mode (/config → Editor mode: vim). The prompt shows -- INSERT --.
  2. Ask: Use the AskUserQuestion tool to ask me which color I prefer: red, green, or blue.
  3. When the multiple-choice prompt appears, press Ctrl-[.

Observed: the question is dismissed and the tool result is User declined to answer questions.

Expected (per the report): Ctrl-[ enters vim normal mode so j/k can navigate the options.

Assessment: This is working as designed, though the underlying limitation is worth understanding. Claude Code does not bind Ctrl-[ to anything. In almost every terminal Ctrl-[ sends exactly the same byte as Escape (0x1B), so the app cannot tell them apart — Ctrl-[ entering normal mode in the main prompt is only because it is Escape there. Unbinding the two keys from each other is not something the app can do. In the question prompt, Escape is documented as cancel (see the Select actions table at https://code.claude.com/docs/en/keybindings and the on-screen hint Esc to cancel), and vim mode only applies to the text input itself (https://code.claude.com/docs/en/keybindings#vim-mode-interaction).

The good news is that there is no normal mode needed for the thing you actually want: j/k (and Ctrl+N/Ctrl+P) already move between options in the question prompt directly, in every mode. So the habit to adjust is just skipping the Ctrl-[ before pressing j/k. If a vim-aware confirmation before cancelling (for example, requiring Escape twice when vim mode is on) would help, that would be a reasonable feature request.

🤖 Generated with Claude Code

bcherny collaborator · 1 month ago

Thanks for the detailed report. I reproduced this on 2.1.233 on Linux in tmux: with vim mode on, Ctrl-[ inside a multiple-choice question dismisses it, exactly as you describe — and the same press in the main prompt enters NORMAL mode.

The cause is terminal input encoding, not a Claude Code mapping: Ctrl-[ and Escape are the same byte (0x1b) in your terminal. I captured the raw input tmux delivers with extended key reporting active, and both keys arrive as an identical single byte, so the app cannot tell them apart. Ctrl-[ "works" as an Escape alias in the main prompt only because it literally is Escape.

Escape canceling the question prompt is intended behavior (it's the on-screen hint: "Esc to cancel"), and vim mode applies to the text editor in the prompt, not to selection menus — see https://code.claude.com/docs/en/interactive-mode. Distinguishing Ctrl-[ from Escape would require a terminal speaking the kitty keyboard protocol end-to-end, which tmux doesn't deliver today.

Good news: the question prompt already supports j/k to move between options directly (plus digits to select), no mode switch needed. Closing the loop on the verdict: working as intended given terminal input encoding.

🤖 Generated with Claude Code

Arthaey · 1 month ago

@bcherny Thank you for the thoughtful response to this issue.

However, there's a much bigger problem than j / k navigation: If I hit Esc within a AskUserQuestion prompt, I lose anything I've typed in the "Other" option (which I do frequently). My dismissed input is not shown in the terminal after the dismissal, so I can't even copy-paste it on a second attempt as a workaround.

Even though I _know_ about this issue, it still bites me at least a couple times a week. 😢

Please reconsider Esc canceling the question prompt as "working as intended" when the user has configured vim mode.