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
/copycomment, the vipe clean-up comment, and the kittystrip_trailing_spaces smartcomment. - Claude Code release notes, read through the GitHub API. Checked: v2.1.59 added the
/copypicker for code blocks or the full response; v2.1.63 added the always-copy-full-response option; v2.1.72 added thewkey 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