Copied text includes 2-space leading indentation from rendered output

Status Open
Maintainer reply None cached
Activity 14 comments · opened Mar 23, 2026

Description

When copying text from Claude Code CLI output in the terminal, each line includes 2 leading spaces that come from the rendering padding. This makes pasted text incorrectly indented, requiring manual cleanup every time.

Steps to reproduce

  1. Run Claude Code in any terminal (iTerm2, Terminal.app, etc.)
  2. Ask Claude any question that produces a text response
  3. Select and copy part of the response
  4. Paste into any text editor

Expected behavior

Copied text should not include the visual padding/margin used for rendering. The clipboard content should match the logical content, not the visual layout.

Actual behavior

Every line of copied text starts with 2 extra spaces. For example, copying a code snippet or explanation results in:

  This is the first line
  This is the second line

instead of:

This is the first line
This is the second line

Impact

  • Pasting code snippets requires manual dedent every time
  • Pasting into chat/docs/emails looks incorrectly formatted
  • Rectangular selection (Alt+drag) is a workaround but not ergonomic for multi-line copies

Suggested fix

Either:

  • Strip the leading padding from the content that the terminal receives (render visually but don't embed in character stream), or
  • Provide a config option to control output padding (e.g., output.padding: 0)

Environment

  • Claude Code: latest
  • Terminal: iTerm2 (also reproducible in Terminal.app)
  • OS: macOS

View original on GitHub ↗

14 Comments

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/18170
  2. https://github.com/anthropics/claude-code/issues/15199
  3. https://github.com/anthropics/claude-code/issues/13378

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

sammcj · 6 months ago

This is quite annoying as it means when copy/pasting output from CC you first have to paste it into an IDE and unindent each line by 2 spaces.

It would be great if Claude Code could output without the two space indentation

0nefinity · 5 months ago

··Would be great to either:
··- Remove the left padding from rendered output, OR
··- Add a setting in settings.json to disable the indent, OR
··- Strip the padding when text is copied to clipboard.

··written by claude code with 2 leading spaces each row

laser · 5 months ago

After using Claude Code all day, every day for months, it was only today that I learned of the /copy command.

Better late than never!

zeroarst · 5 months ago

Another issue is that long link in Claude code is broken in Windows terminal, because the indentation.
Can we have a setting to remove them?

<img width="1898" height="393" alt="Image" src="https://github.com/user-attachments/assets/c954bc16-a742-4645-a418-cd0ddeaf4426" />

Zaegan · 5 months ago

Workaround for those who need clean output now: in a separate terminal (outside Claude Code), run watch -n1 "cat /tmp/claude/response.md | sed 's/^ //'" to monitor the file. Then, within Claude Code, run /copy after any response you want to read cleanly — this writes the last response to /tmp/claude/response.md and
the watch command will immediately display it without the leading spaces.

C0RE1312 · 4 months ago

Please we need to be able to copy commands just from the terminal, everything else is taking too long.

kingspride · 4 months ago

most terminals pad their content anyways so its just a useless feature to pad the whole CLI program with 2 spaces..

david7902 · 4 months ago

I run into issue with this all the time doing terminal work with indent sensitive config updates, python, etc. Even an obscure setting to turn off the indent would be a huge win.

samlaf · 4 months ago

+1 - please address this. My current workaround is to ask claude to write to a tmp file which I then copy-paste from, but its quite tedious.

bw2 · 2 months ago

+1

kingspride · 2 months ago

for a while now, Claude Code CLI offers a custom selection mode that overrides the terminals own text marking:

<img width="1717" height="1495" alt="Image" src="https://github.com/user-attachments/assets/2619c430-0238-4ea5-baa5-9783673a1668" />

this fixed the issue for me.
as you can see, it copies without the left padding.

def greet(name="world"):
    message = f"Hello, {name}!"
    print(message)
    return message

if __name__ == "__main__":
    greet()

I dont know if this works in other terminals, but on Windows with the Windows Terminal and Claude Code CLI running in WSL, it works remarkably well.

Single paragraphs are even copied correctly as single lines until there is a real line break

Bishop81 · 2 months ago

I used to ask Claude Code to write to a file for me, but then built this tool to fix the issue: https://pypi.org/project/unwrap-terminal-text/

It's simple, but I really do find myself using it multiple times a day now

nullzone · 4 days ago

Mac users:

  • iTerm2: Cmd+Option+drag
  • Terminal.app: Option+drag