Escape Key Conflict in Embedded Terminal Mode

Status Fixed / completed
Maintainer reply ✓ Yes — ashwin-ant
Activity 12 comments · opened Feb 24, 2025 · closed Mar 28, 2025
💡 Likely answer: A maintainer (ashwin-ant, collaborator) responded on this thread — see the highlighted reply below.

Bug Description

"Escape" to cancel an action or exit a menu conflicts when running claude in an embedded terminal in vim/neovim. Please provide an alternative key mapping (left arrow) or ability to configure key mappings manually.

Environment Info

  • Platform: macos
  • Terminal: tmux
  • Version: 0.2.9
  • Feedback ID: f4f57ea5-974f-420b-b14d-b6a780c4cf7e

!Image

View original on GitHub ↗

12 Comments

IAMtheIAM · 1 year ago

I'm unable to escape from any command using an emdedded terminal in IntelliJ IDEA Ultimate.

AJM10565 · 1 year ago

@IAMtheIAM control + escape for IntelliJ IDEA Ultimate on the Mac seems to work, at least in the latest update.

ashwin-ant collaborator · 1 year ago

@IAMtheIAM that's due to Jetbrains IDEs having a default keyboard shortcut that maps Esc to switching focus back to the editor. You can resolve this by following these steps: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003508579/comments/360001567559. Essentially, either change or remove the key mapping. I followed them myself and can confirm that it works.

ashwin-ant collaborator · 1 year ago

@robcmills are you still experiencing this issue?

robcmills · 1 year ago

@ashwin-ant Yes I am still experiencing this issue.

ashwin-ant collaborator · 1 year ago

Can you share any more details of your setup? I'm trying to repro in vim via :term, and also doing so within tmux, and I'm having trouble reproducing the issue.

robcmills · 1 year ago

@ashwin-ant Sure. It is probably because of my custom bindings. Let me put together a summary real quick, one sec...

robcmills · 1 year ago

@ashwin-ant Add this key binding to your init.lua:

vim.keymap.set('t', '<Esc>', '<C-\\><C-n>', { desc = 'Exit insert mode in terminal' })

I think this is a pretty common keybinding in neovim, since the default is so obtuse.
So you can see that when I press escape, it just exits terminal mode, and claude-code never receives it. Thus, the only way to exit is Ctrl-C, unless I give up one of my most used and beloved key bindings...

robcmills · 1 year ago

@ashwin-ant I guess the workaround is pretty obvious, I could just use a different key to escape terminal mode in my config.

So maybe this is not an issue, but more of a feature request: add ability to customize key bindings.
Or the quick fix I mentioned in original comment: add alternate escape key

I'd be okay with that if you want to close this ticket as a non-issue. 👍

ashwin-ant collaborator · 1 year ago

We may revisit custom keybindings in the future, thanks for reporting!

robcmills · 1 year ago

Not to throw shade, but OpenAI Codex offers exactly what I was asking for: _alternate key to close_

!Image

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.