claude-code - 💡(How to fix) Fix Ctrl+G external editor on Windows: arrow-key escape sequences not forwarded to child PTY (Helix unusable)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

On Windows, pressing Ctrl+G to open $EDITOR (Helix in my case) launches the editor, but CSI escape sequences for arrow keys are not forwarded intact. After pressing Esc to enter Helix normal mode, the right arrow (which should send ESC [ C) is delivered to Helix as a bare C — arrow keys behave as if the ESC [ prefix was stripped or consumed. Left/up/down behave the same.

Helix works correctly when launched directly from the same terminal (Windows Terminal + PowerShell, or Git Bash). Only the Claude-Code-spawned instance is broken.

Root Cause

On Windows, pressing Ctrl+G to open $EDITOR (Helix in my case) launches the editor, but CSI escape sequences for arrow keys are not forwarded intact. After pressing Esc to enter Helix normal mode, the right arrow (which should send ESC [ C) is delivered to Helix as a bare C — arrow keys behave as if the ESC [ prefix was stripped or consumed. Left/up/down behave the same.

Helix works correctly when launched directly from the same terminal (Windows Terminal + PowerShell, or Git Bash). Only the Claude-Code-spawned instance is broken.

Fix Action

Workaround

Wrap the editor in a .cmd that uses start "Helix" /wait hx.exe %*. This spawns a new console window with a fresh TTY and blocks until the editor exits. Suggests the issue is specifically with how Claude Code's embedded PTY forwards escape sequences to the spawned child — not a PATH/env issue, since the fresh console works fine.

RAW_BUFFERClick to expand / collapse

Summary

On Windows, pressing Ctrl+G to open $EDITOR (Helix in my case) launches the editor, but CSI escape sequences for arrow keys are not forwarded intact. After pressing Esc to enter Helix normal mode, the right arrow (which should send ESC [ C) is delivered to Helix as a bare C — arrow keys behave as if the ESC [ prefix was stripped or consumed. Left/up/down behave the same.

Helix works correctly when launched directly from the same terminal (Windows Terminal + PowerShell, or Git Bash). Only the Claude-Code-spawned instance is broken.

Steps to reproduce

  1. On Windows, install Helix and set EDITOR=C:\path\to\hx.exe
  2. Launch Claude Code in Windows Terminal (tried both PowerShell and Git Bash)
  3. Press Ctrl+G in the chat input
  4. In Helix: type some text (insert mode works fine), press Esc → press right arrow
  5. Observe: C command triggered (change selection) instead of cursor-right

Expected

Helix receives full escape sequences (ESC [ A/B/C/D) for arrow keys, same as when launched directly.

Actual

Only the final character of the escape sequence reaches Helix. Esc appears to be consumed or split from its trailing [ X.

Environment

  • OS: Windows 11 Enterprise 10.0.26200
  • Terminal: Windows Terminal (default settings)
  • Shells tried: PowerShell 5.1, Git Bash (bash 5.x)
  • Claude Code: 2.1.116
  • Node: v22.22.2
  • Editor: Helix 25.07.1
  • TERM=xterm-256color

Workaround

Wrap the editor in a .cmd that uses start "Helix" /wait hx.exe %*. This spawns a new console window with a fresh TTY and blocks until the editor exits. Suggests the issue is specifically with how Claude Code's embedded PTY forwards escape sequences to the spawned child — not a PATH/env issue, since the fresh console works fine.

Note

Presumably affects any terminal-mode editor (vim, nvim, nano, micro) on Windows, not just Helix.

extent analysis

TL;DR

The issue can be worked around by wrapping the editor in a .cmd file that uses start "Helix" /wait hx.exe %* to spawn a new console window with a fresh TTY.

Guidance

  • The problem seems to be related to how Claude Code's embedded PTY forwards escape sequences to the spawned child process, specifically on Windows.
  • To verify, try launching the editor directly from the terminal and compare the behavior with the Claude Code-spawned instance.
  • The provided workaround using a .cmd file suggests that creating a new console window with a fresh TTY resolves the issue.
  • Investigate the PTY implementation in Claude Code to determine why the escape sequences are being stripped or consumed.

Example

No code snippet is provided as the issue is more related to the environment and PTY implementation.

Notes

The issue may affect other terminal-mode editors on Windows, not just Helix, as mentioned in the note. The workaround may not be the final solution but provides a temporary fix.

Recommendation

Apply the workaround by wrapping the editor in a .cmd file, as it provides a functional solution to the problem, although it may not address the root cause of the issue with Claude Code's PTY implementation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Ctrl+G external editor on Windows: arrow-key escape sequences not forwarded to child PTY (Helix unusable)