Vim mode: Ctrl-[ dismisses AskUserQuestion prompts instead of entering normal mode
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
- Enable vim mode (
/vim). - Get Claude to ask a question via the multiple-choice question prompt.
- 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 thatCtrl-[ 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
3 Comments
Reproduced on v2.1.233 (macOS, tmux) in the sense that the key does dismiss the prompt.
Steps:
/config→ Editor mode: vim). The prompt shows-- INSERT --.Use the AskUserQuestion tool to ask me which color I prefer: red, green, or blue.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 soj/kcan 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 terminalCtrl-[sends exactly the same byte asEscape(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 hintEsc 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(andCtrl+N/Ctrl+P) already move between options in the question prompt directly, in every mode. So the habit to adjust is just skipping theCtrl-[before pressingj/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
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/kto 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
@bcherny Thank you for the thoughtful response to this issue.
However, there's a much bigger problem than
j / knavigation: If I hitEscwithin 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.