published fresh until

How do I copy text from Claude Code without the extra indentation?

Summary If copying selected Claude Code terminal text adds padding or trailing spaces, try /copy for a clean code block or full response; issue 18170 remains open as of November 2026, and terminal tweaks help only in some terminals.

Not for Claude Code keybinding changes such as Enter for newline; see claude-code-enter-newline-keybinding-send-key

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

Selecting text in the Claude Code terminal and pasting it elsewhere brings the visual padding along: leading spaces on every line, trailing spaces, and sometimes hard line breaks at the terminal width. As of November 2026, the GitHub issue is open. Commenters say it breaks pasted multi-line shell commands and heredocs, in one case a udev rule with leading whitespace that was silently ignored.

What worked for commenters

1. /copy. A commenter wrote that telling Claude Code /copy lets you copy the code block cleanly. The release notes list a /copy picker (v2.1.59) for individual code blocks or the full response, an "always copy full response" option, /copy N for the Nth response back (v2.1.77), and a w key to write the selection to a file, useful over SSH (v2.1.72). Others said /copy helps but is more work than selecting a few lines, and that over SSH the clipboard may not work. 2. Edit what is on the clipboard. One commenter ran pbpaste | vipe | pbcopy to clean up in an editor. On macOS this needs vipe from moreutils installed separately; that is a third-party install. 3. Terminal-side trimming. A kitty user reported that strip_trailing_spaces smart in kitty.conf removes the trailing spaces (tested on Fedora 42, kitty 0.43.1, by that commenter), and said it does nothing for gnome-terminal, VS Code or macOS Terminal. A tmux copy binding that strips whitespace was also suggested. 4. Ask Claude to put the text on the clipboard. Commenters had Claude write a command to a temp file and pipe it to pbcopy, wl-copy or xclip. A partial fix: the CLAUDE.md instruction can't select arbitrary text.

Caveats

  • Several commenters promoted small paste-cleanup apps; one warned a closed-source one reads your clipboard. Treat these as untrusted.
  • None of this is a root-cause fix. No maintainer reply appears in the thread as of this writing.
  • Windows/PowerShell users reported accented characters breaking and fixed it by setting UTF-8 console output in their profile (reported by a commenter).

Takeaway

Use /copy for responses and code blocks, check your terminal for a trailing-space option, and never paste a multi-line command into a shell without looking at it first.

Sources

  • anthropics/claude-code issue 18170, read through the GitHub API. Checked: opened 2026-01-14 by radrob2, open; no comment from a member, owner or collaborator account; the /copy comment, the vipe clean-up comment, and the kitty strip_trailing_spaces smart comment.
  • Claude Code release notes, read through the GitHub API. Checked: v2.1.59 added the /copy picker for code blocks or the full response; v2.1.63 added the always-copy-full-response option; v2.1.72 added the w key to write the selection to a file; v2.1.77 added /copy N; fixes for clipboard use inside tmux and SSH are listed in several later versions.

Not checked: that the kitty setting works (only the commenter's own test is reported), the tmux binding, the Windows UTF-8 profile fix, and whether any of this changes the root cause. A commenter's note that the terminal has a default and a fullscreen mode was not examined here. Nothing was run.

Started from a post by @radrob2, packaged by the editor. Original post

Subjects

More in agents.md

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I copy text from Claude Code without the extra indentation?
Summary: If copying selected Claude Code terminal text adds padding or trailing spaces, try `/copy` for a clean code block or full response; issue 18170 remains open as of November 2026, and terminal tweaks help only in some terminals.
Copy for agent
get the whatworks thread claude-code-copy-code-block-clean and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-copy-code-block-clean
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks