2-space indent and hard wrap at 80 breaks copy-paste - Need a way to configure it out of the way
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?
## Description
Claude Code adds a 2-space indent to all code block content and hard-wraps at ~80
characters. When copying commands from the terminal, these artifacts get included,
breaking pasted commands.
## The Irony
I am posting this bug report verbatim as Claude Code output it - complete with the
2-space indent and 80-char wrap. The bug demonstrates itself.
## Environment
- Claude Code version: [run
claude --version] - Terminal: [your terminal]
- OS: [your OS]
## Related Issues
#4686, #6827, #4004
What Should Happen?
## Expected Behavior
Either:
- No indent in code blocks
- Soft wrap instead of hard wrap
- Or: a config option to disable this formatting (
--no-indent,--no-wrap, etc.)
Error Messages/Logs
n/a
Steps to Reproduce
## Steps to Reproduce
- Ask Claude Code for any command longer than 80 characters
- Copy from terminal
- Paste - note extra spaces where lines wrapped
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.61
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
<img width="629" height="313" alt="Image" src="https://github.com/user-attachments/assets/129d92e5-5748-4b52-b0c0-ef413ee23557" />
Pardon my irritation. I feel like I step on this landmine 10 times a day.
16 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
It's a somewhat different idea how to deal with the same problem.
``
--no-indent, --no-wrap, etc.``I also have this issue. Im on macos. Very frustrating
+1 Same issue here.
The 2-space indentation makes copy-paste unusable. Would appreciate a config option to disable it.
This is super unuseful if you NEED to copy paste shell scripts, because claude code is not allowed to connect to other machines.
Simple change would be: Output code as is. No formating. Or it would be useful if the indentation could be turned off when you copy text from the terminal... or something which cleans up the copied text.
/copyis a good partial workaround for right now:Usage
<details><summary>Expand</summary>
<p>
<img width="1000" alt="Image" src="https://github.com/user-attachments/assets/556f7b60-3ea8-477b-91a9-acd1f7d523d3" />
Before
---
After
---
</p>
</details>
Full Solutions
---
I still think this is annoying, because you can't copy multiple responses and format them correctly; I end up having to have the agent output it into
pbcopywhich is a waste of tokens (repeating the request), but it's an improved experience.configto turn off the⏺and 2-sp indentctrl+ckeypress action that strips⏺characters, extra spaces, and the claude-code special linebreaks, piping topbcopyWorkaround: "Clean Paste" script
Until this is configurable, here's a workaround script that would work with any keyboard-binding program or solution. I used Raycast's script commands since it was free to download. The script cleans Claude Code formatting from the clipboard on paste. Bind it to a hotkey (e.g.,
Cmd+Ctrl+V) and use it instead of regular paste, so that you can copy multiple claude code output blocks and have all the wrapping and indentation stripped.Also works as a standalone clipboard cleaner without Raycast, could make an
ccor something along those lines to cleanup the last copied clipboard record — just remove the Raycast metadata comments and the finalosascriptline, then run it after you copy something.What it fixes
⏺bullet prefix\ninserted at terminal width)preserved, while mid-sentence word wraps get rejoined.
Raycast Instructions
<details><summary>Expand</summary>
<p>
Regex Script
mkdir -p ~/shortcuts/scripts/open ~/shortcuts/scripts/clean-paste.shand copy the below in.chmod +x ~/shortcuts/scripts/clean-paste.shKeyboard Shortcut
| Settings > Extensions > Scripts | Add Script Directory<br>
~/shortcuts/scripts| Clean Paste should auto-populate ||--------|--------|-------|
| <img width="200" height="238" alt="Image" src="https://github.com/user-attachments/assets/0509a4b1-aa23-4027-9948-85fbd7b98a10" /> | <img width="200" alt="Image" src="https://github.com/user-attachments/assets/de3116e2-663e-4778-81d8-02fce4b421b7" /> | <img width="500" alt="Image" src="https://github.com/user-attachments/assets/c660b3e0-1bc1-479e-93dc-1d9b38f26af5" /> |
</p>
</details>
Examples
<details><summary>Expand</summary>
<p>
_using raw text because the line breaks are getting automatically filtered out in the codeblock, so does not show the issue effectively._
Before (raw Cmd+V from iTerm copy):
---
⏺ You can change it in Raycast Settings → Extensions → Scripts → click the hotkey field for Clean Copy → press Shift+Ctrl+A. That's a
Raycast UI setting, not something in the script file.
❯ We can't pass the selected text in like a param or anything?
⏺ Web Search("Raycast script command receive selected text input clipboard argument")
⎿ Did 1 search in 6s
⏺ Raycast has Pipe Commands — they receive selected text via stdin and output replaces the clipboard. But that requires the Pipe Commands
extension, and pipe commands can't have hotkeys.
For script commands, Raycast can pass clipboard content as stdin with @raycast.currentDirectoryPath ... actually the simpler approach:
since Raycast script commands can read the clipboard directly, and the issue is just that the hotkey triggers before you've copied — what
if we skip the osascript entirely and just use @raycast.input source?
Let me check the exact metadata:
---
After (Clean Paste):
---
You can change it in Raycast Settings → Extensions → Scripts → click the hotkey field for Clean Copy → press Shift+Ctrl+A. That's a Raycast UI setting, not something in the script file.
❯ We can't pass the selected text in like a param or anything?
Web Search("Raycast script command receive selected text input clipboard argument")
⎿ Did 1 search in 6s
Raycast has Pipe Commands — they receive selected text via stdin and output replaces the clipboard. But that requires the Pipe Commands extension, and pipe commands can't have hotkeys.
For script commands, Raycast can pass clipboard content as stdin with @raycast.currentDirectoryPath ... actually the simpler approach:
since Raycast script commands can read the clipboard directly, and the issue is just that the hotkey triggers before you've copied — what if we skip the osascript entirely and just use @raycast.input source?
Let me check the exact metadata:
---
</p>
</details>
#18170 describes this issue and has 40 participants (this ticket has 5). Please add a comment there as well so we hopefully get Anthropic's attention by crossing the 50 mark. Thanks.
this is indeed super irritating, why would they add such a stupid "feature"?
I faced same issue and I had to revert from 2.1.87 (ironically latest stable version) to claude 2.1.58 (previous stable).
Other annoying thing is Claude Code github repo hides the Release and Tags Link to download the binaries.
https://github.com/anthropics/claude-code/releases
https://github.com/anthropics/claude-code/tags
same issue in Ghostty on macOS, affects both prose and code blocks
i can't believe how long such a simple and stupid bug has been sitting here. literally ask claude to fix it and it will be gone in like 20 seconds.
The core ask is simple: use soft wrapping for code block content only — emit long lines without inserting hard \n
characters, and let the terminal emulator handle visual wrapping. The TUI chrome (spinners, separators, progress
bars) can keep using terminal width — only code block text needs to change.
Why this matters:
artifacts instead of a runnable one-liner
/copy works but requires an extra step every single time
not planned, same root cause)
The fix is surgical: don't call the hard-wrap renderer for fenced code block content. Emit the raw line and let the
terminal wrap it visually. This is standard behavior for every other terminal tool that outputs code.
Nine months on and the entire thread is people building external clipboard-scrubbers (Raycast scripts,
perlone-liners,cclip) to undo formatting the renderer never should have baked into the buffer. That's the tell: the workarounds exist because the TUI is fighting the terminal's own selection, and every one of them is a per-user, per-OS band-aid for something that should be a single setting./copyisn't the fix either. It only grabs the last assistant turn, it can't span multiple responses, and it does nothing for the far more common case — dragging a normal terminal selection across part of a code block. The 2-space indent and hard-wrap-at-80 corrupt that selection every time, and no amount of/copyhelps because you're not always copying a whole response.The core problem is that presentation is being written into the copyable text. The indent and the hard newlines are display chrome; they belong in the render layer, not in what my terminal hands to the clipboard. Please give us a config key to turn it off —
disableOutputIndent/ soft-wrap instead of hard-wrap, whatever the shape. Even just not injecting the leading 2 spaces and⏺into selectable output would fix 90% of the pain without touching the visual layout.This is a papercut that draws blood a dozen times a day. It's not cosmetic — it silently corrupts pasted shell commands, which is a correctness bug for anyone who copies commands out to run them elsewhere.
Adding measured frequency data, since this thread is long on anecdote and short on numbers. Claude Code 2.1.221, Linux, ~80-col terminal.
How often it actually bites. I scanned my full local transcript history — 509 sessions, 6,729 assistant text messages — counting fenced code-block lines that exceed the usable width (terminal columns minus the 2-space margin):
| | count |
|---|---|
| assistant text messages | 6,729 |
| containing a >78-char code-block line | 91 (1.4%) |
So roughly one message in seventy ships a command that will be corrupted on copy. That is not an edge case, and it is invisible to the model producing it.
The two artifacts are not equally harmful, which I think is worth separating in triage:
EOFnever matches its terminator, so the shell hangs on>until you Ctrl-C) and any paste into a REPL or YAML..../scr+atchpad/...and produced twoNo such file or directoryerrors. No amount of careful selection recovers it.The wrap is the one worth prioritizing. As noted upthread, soft-wrapping code block content only — emitting long lines and letting the emulator wrap them visually — fixes it without touching TUI chrome.
Interim mitigation, if it helps anyone here. Rather than scrubbing the clipboard after the fact, this can be caught before the text is ever emitted, with a
Stophook that inspects the outgoing message and refuses to end the turn while a pasteable code block contains an over-long line. The one non-obvious part: the hook's own stdout is a captured pipe, so it can't read the width from its fds — but it is a descendant of the Claude Code process and shares the controlling terminal, soioctl(TIOCGWINSZ)on/dev/ttyreturns the true column count, and the limit tracks window resizes. Falling back through own-fds → walking the process tree for an ancestor's terminal →$COLUMNS→ 80 covers the rest.Replayed against the message that originally broke for me, it blocks with the offending line and its length, and the model reroutes to writing a file plus a short runner command. It's a workaround for the same root cause everyone else is working around, just applied before the buffer instead of after the clipboard — but it does mean the fix doesn't depend on the user noticing.
Happy to share the hook if useful. The underlying ask stands: soft wrap for code block content.
Not bulletproof, but here's a tool I built for this very issue: https://pypi.org/project/unwrap-terminal-text/. Works really well for me, anyway