[BUG] "edit in nvim" breaks terminal rendering

Status Fixed / completed
Maintainer reply None cached
Activity 15 comments · opened Oct 8, 2025 · closed Dec 10, 2025

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

With the new feature "edit prompt in nvim" (ctrl+g), on macOS, doing that breaks tui if a window is opened, and then an up arrow is pressed, or while Claude is working. This shows the regular claude window, and vim at the same time, alternating each frame. This leads to all kinds of jank:

<img width="1609" height="885" alt="Image" src="https://github.com/user-attachments/assets/07042ce5-2617-4d49-9580-2924ef024e78" />

I'm using Ghostty on MacOS, and nvim 0.11.4 as my editor.

What Should Happen?

no glitches

Error Messages/Logs

Steps to Reproduce

Included above

Claude Model

Not sure / Multiple models

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.0.10

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

15 Comments

github-actions[bot] · 10 months ago

Found 1 possible duplicate issue:

  1. https://github.com/anthropics/claude-code/issues/9130

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

jbwashington · 10 months ago

having the same issue; thought it was vim plugins causing the issue so i disabled everything and just made it vanilla... same issue.

running macOS Tahoe, claude code v 2.0.10 with native install, Ghostty terminal

iq-mschmeets · 10 months ago

Also see this issue with:

Environment

  • OS: Linux (Fedora 42, kernel 6.16.10-200.fc42.x86_64)
  • Terminal: Tested across multiple emulators with identical failures:
  • ghostty (with and without tmux)
  • gnome-terminal
  • tmux in ghostty
  • $TERM: xterm-256color
  • $EDITOR: vim (primary test), also tested with nano

Behavior

  1. vim: The terminal opens something that looks like "corrupted vim", ctrl chars, odd lines.
  2. nano: Nano opens and I can edit text, but it won't save, constantly prompts for new file name.

In the vim case the terminal becomes unresponsive and I cannot return claude, have to close terminal window. With nano, I can exit nano but the text is not picked up by claude.

Additional Context

This appears to be an issue with how Claude Code is:

Launching the external editor process
Capturing/restoring terminal state before/after editor invocation
Handling the terminal escape sequences for the editor session
The consistency across multiple terminal emulators suggests the issue is in Claude Code's terminal state management rather than terminal-specific behavior.

asmeurer · 10 months ago

Also happens with terminal emacs and iTerm2. I'm not even sure how it's possible but the terminal state got so borked that even exiting to bash and typing reset did not fix it. I had to completely restart a new terminal.

jakubbortlik · 10 months ago

I'm using this workaround which opens a Neovim instance in a tmux popup if in a tmux session, else it opens neovim in a new foot terminal. I've got this simple script in ~/local/bin/claude-editor.sh:

#!/bin/bash
if [[ $TMUX != "" ]]; then
  tmux display-popup -E "nvim" "$@"
else
  foot nvim "$@"
fi

And then I put this into ~/.claude/settings.json:

{
  "env": {
    "EDITOR": "/home/myname/local/bin/claude-editor.sh"
  }
}
zzJinux · 10 months ago

Also happens with NVIM v0.11.3, iTerm2 3.6.4 and Claude Code 2.0.14

Foxfire1st · 10 months ago

Also happens when hitting crtl-g to edit in vscode. It breaks the Claude instance and I am left with a black screen and cannot return to Claude Code anymore.

jackielii · 10 months ago
I'm using this workaround which opens a Neovim instance in a tmux popup if in a tmux session, else it opens neovim in a new foot terminal. I've got this simple script in ~/local/bin/claude-editor.sh: #!/bin/bash if [[ $TMUX != "" ]]; then tmux display-popup -E "nvim" "$@" else foot nvim "$@" fi And then I put this into ~/.claude/settings.json: { "env": { "EDITOR": "/home/myname/local/bin/claude-editor.sh" } }

This is a good work around, and I think I need it anyway to customise the floating pane. Although I found you need to set both EDITOR and VISUAL:

  "env": {
    "EDITOR": "~/.claude/claude-editor.sh",
    "VISUAL": "~/.claude/claude-editor.sh"
  },

Also want to share my editor script, maybe useful:

#!/bin/bash

if [[ $TMUX != "" ]]; then
  tmux display-popup -E -w 90% -h 90% nvim "$@"
elif [[ -n "$KITTY_WINDOW_ID" ]]; then
  kitten @ launch --type=overlay \
    --color background=#1a1a2e \
    --logo="$HOME/.claude/claude-logo.png" \
    --logo-position=bottom-right \
    --logo-alpha=0.4 \
    nvim -c "hi Normal guibg=NONE ctermbg=NONE" -c "hi NormalNC guibg=NONE ctermbg=NONE" "$@"
else
  nvim "$@"
fi

Update: kitty launch doesn't block. So when it exits immediately, claude removes the temp file so there was nothing to be edited. The correct one should be:

  kitten @ launch --type=overlay \
    --wait-for-child-to-exit \
    --title="Claude Code Editor" \
    --color background=#1a1a2e \
    --logo="$HOME/.claude/claude-logo.png" \
    --logo-position=bottom-right \
    --logo-alpha=0.4 \
    nvim -c "hi Normal guibg=NONE ctermbg=NONE" -c "hi NormalNC guibg=NONE ctermbg=NONE" "$@"

And there was a bug in --wait-for-child-to-exit and fixed in https://github.com/kovidgoyal/kitty/pull/9165

eliasnorrby · 10 months ago
Although I found you need to set both EDITOR and VISUAL

My experience is claude will prioritize VISUAL over EDITOR. You only need to set one, but if you have VISUAL set to e.g. nvim in your shell environment, it won't do to set just EDITOR in settings.json.

---

And thank you @jakubbortlik! I quickly found I often want to minimize the popup in order to gather context for the prompt I'm writing, so I went a little off the rails and turned it into a stateful popup that can be toggled and resurfaced across different tmux windows. Source

jackielii · 10 months ago
My experience is claude will prioritize VISUAL over EDITOR. You only need to set one, but if you have VISUAL set to e.g. nvim in your shell environment, it won't do to set just EDITOR in settings.json.

Thanks. I started with just EDITOR, it just didn't work for me, maybe I already have VISUAL in the parent env... So, to be on the safe side, I set both.

github-actions[bot] · 8 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

Nek-12 · 8 months ago

Don't close this issue. This is an automatic message by Fresh - a bot against stale bots.

jakubbortlik · 8 months ago
Don't close this issue. This is an automatic message by Fresh - a bot against stale bots.

@Nek-12 I know that the "stale bots" can be annoying, but if you had checked, you would've found out that this issue is actually resolved in recent versions of Claude Code, hence keeping the issue open adds unnecessary work for the developers. In a repo with over 5 thousand open issues this is not helping.

Nek-12 · 8 months ago

@jakubbortlik If the bug has been fixed, then the issue should've been closed by maintainers. I'm not responsible for 5000 issues opened, I opened an issue on a legitimate bug. thanks.

github-actions[bot] · 8 months 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.