How to Copy man Pages and --help Without Broken Wraps
man pages and --help output are written for a terminal that wraps text at the current width. When the developer copies that text, the wrap becomes a hard line break in the copied content. A sentence that should be one line becomes three lines, with breaks at column 80 (or whatever the terminal width is). Pasting that into a note, a chat message, or a script produces text with random mid-sentence breaks that are annoying to read and break parsers. The fix is either to disable wrapping before copying, or to post-process the copied text to remove the wrap-induced breaks.
This guide is about copying from man pages and --help output cleanly, without soft-wrap artefacts. It is written for developers using bash, zsh, or PowerShell on Windows Terminal, WSL, or Linux. For neighbouring topics, see Docker IDs, Kube contexts, and pin hygiene, browser DevTools copy options explained, best clipboard habits for developers in 2026, and copying error logs without taking half the console for the related trimming discipline that often follows a --help lookup.
Why the wrap happens
Terminal applications — man, less, most, groff, and most CLI tools — query the terminal's width on startup (via the COLUMNS environment variable or the ioctl syscall) and wrap output to that width. A terminal that is 120 columns wide produces output wrapped at column 120; a terminal that is 80 columns wide produces output wrapped at column 80. The wrap is a property of the rendered output, not of the source text.
When the developer selects and copies the rendered output, the wrap is part of the copied text. The original source (the man page source, the --help string in the binary) has no wrap; the wrap was introduced by the renderer for display purposes. Copying the display captures the wrap as a hard line break.
The result: copied man page content has line breaks at irregular intervals (matching the terminal width at copy time), and pasting that content into a wider target (a note, a chat message, a script) preserves the breaks. The text looks fine in the original terminal and broken everywhere else.
Disabling the wrap before copying
The cleanest fix is to render the source without a wrap, then copy.
For man pages
Set the MANWIDTH environment variable to a large value before invoking man:
MANWIDTH=9999 man grep
This tells man to render at 9999 columns, which effectively disables wrapping for any practical terminal. The output is one long line per paragraph, which copies cleanly.
For a permanent fix, add to ~/.bashrc or ~/.zshrc:
export MANWIDTH=9999
This affects every man invocation in the shell. The trade-off is that man pages display with very long lines in the terminal, which is harder to read interactively. For developers who copy from man more often than they read it interactively, the trade-off is worth it. For developers who read interactively more often, leave MANWIDTH unset and set it inline when copying.
For --help output
Most CLI tools respect the COLUMNS environment variable:
COLUMNS=9999 ls --help
COLUMNS=9999 kubectl --help
Some tools (notably those built with Python's argparse or click libraries) respect COLUMNS; others do not. For tools that do not, the wrap is built into the tool's source code and cannot be overridden from the environment.
For less (the default man pager)
less wraps long lines by default. Disable wrapping with the -S flag (chop long lines) or by setting LESS:
less -S file.txt
# Or, permanently:
export LESS="-S"
With -S, less shows long lines truncated at the terminal width; the rest of the line is visible by scrolling right with the arrow keys. Copying from less -S captures the visible portion only, which is the same as the wrapped version. The fix here is MANWIDTH, not less -S.
For PowerShell Get-Help
PowerShell's Get-Help wraps at the console width. To get unwrapped output, pipe through Out-String -Width:
Get-Help Get-Process | Out-String -Width 9999
Or, for permanent use, define a function:
function Get-HelpWide($cmd) {
Get-Help $cmd | Out-String -Width 9999
}
Post-processing the wrap out
For content already copied with wraps, post-processing can remove the wrap-induced breaks. The pattern: replace a newline that is preceded by a non-punctuation character and followed by a lowercase letter with a space. This re-joins lines that were wrapped mid-sentence without affecting intentional paragraph breaks.
In sed:
sed ':a;N;$!ba;s/\n\([a-z]\)/ \1/g'
In Python:
import re
import sys
text = sys.stdin.read()
# Join lines that end with a non-punctuation, non-digit character and start with lowercase
text = re.sub(r'(?<=[^\n.!?;:])\n(?=[a-z])', ' ', text)
print(text)
These heuristics are not perfect. They will mis-join some list items and miss some wrapped sentences. For most man page and --help output, they produce clean text. For critical use cases, disable the wrap before copying instead.
Piping to a file instead of copying
The cleanest pattern is to skip the clipboard entirely. man output, --help output, and any other terminal output can be redirected to a file:
man grep > grep.txt
ls --help > ls-help.txt
The file contains the wrapped output (same as a copy), but the developer can post-process it in place with sed or a script, and the result is persistent — no clipboard to lose, no truncation, no formatting issues. The file can be opened in an editor for reading, grepped for specific terms, or referenced later.
For man pages specifically, the source (groff format) is also available:
man -w grep
# Returns: /usr/share/man/man1/grep.1.gz
zcat /usr/share/man/man1/grep.1.gz
The groff source has no wrap; it is the canonical text. Rendering it with groff -Tutf8 -man produces the wrapped output. For developers who need the canonical text, reading the groff source is the right approach.
Common copy targets and their wrap behaviour
| Target | Behaviour with wrapped text |
|---|---|
| Slack | Renders wrapped text with the breaks visible. Looks bad. |
| Same as Slack. Looks bad. | |
| VS Code | Renders wrapped text with breaks. Editor can be set to wrap visually, but the breaks are still in the file. |
| Notepad / plain text editor | Renders breaks as-is. |
| Markdown renderer | A single newline in Markdown is rendered as a space; a double newline is a paragraph break. Wrapped man output with single newlines will render as one paragraph, which is usually what the developer wants. |
| Word / Google Docs | Renders breaks as paragraph breaks. Looks terrible. |
| Terminal | Renders breaks as-is. Looks the same as the original. |
For Markdown targets (chat tools that support Markdown, GitHub, README files), the wrap is less of a problem because Markdown collapses single newlines. For rich-text targets (Word, Google Docs, email), the wrap is a major problem.
A practical workflow
For developers who copy from man and --help regularly:
- Set
MANWIDTH=9999in~/.bashrcor~/.zshrc. This fixesmanpages permanently. - Set
COLUMNS=9999inline when invoking--helpfor tools that respect it.COLUMNS=9999 kubectl --help. - Pipe to a file for content that needs to be referenced repeatedly.
man grep > grep.txt. - Post-process with
sedfor content already copied. Thesedone-liner above handles most cases. - Use Markdown targets when possible. The wrap collapses in Markdown rendering, so single-newline wraps become spaces.
With these five habits, the wrap artefact is no longer a problem. The developer copies from man and --help cleanly, and the pasted text reads naturally in any target.
When to skip the copy entirely
Some man page and --help lookups are better served by a different source entirely. The official documentation for the tool — hosted on the vendor's website or in the project's docs — is often more readable than the man page, is searchable, and has none of the wrap issues described above. For example:
kubectldocumentation on kubernetes.io is more structured thankubectl --help, with examples, use cases, and cross-references.gitdocumentation on git-scm.com includes the full reference, the Pro Git book, and tutorials.- PowerShell cmdlet documentation on Microsoft Learn includes examples, parameter descriptions, and related cmdlets.
For a developer who needs to understand a tool deeply, the web docs are the right source. For a developer who needs a quick reminder of a flag's syntax, --help is faster. The clipboard hygiene matters in both cases, but the source choice is a separate decision. The discipline is: pick the source that matches the depth of the question, and apply the wrap-removal techniques if the source is the terminal.
Related reading
- Browser DevTools Copy Options Explained
- Postman and Insomnia: Collections Beat Clips
- Best Clipboard Habits for Developers in 2026
- Clipboard Tools on Multi-Monitor Windows Setups
Sources
- Linux man-pages project — MANWIDTH — the Linux man-pages project documentation, which describes the
MANWIDTHenvironment variable and howmanuses it - GNU coreutils — COLUMNS environment variable — GNU coreutils documentation for the
COLUMNSenvironment variable, respected by many CLI tools - less — documentation — official documentation for
less, including the-Sflag for chopping long lines - PowerShell — Out-String cmdlet — official documentation for
Out-String, including the-Widthparameter for controlling wrap width - groff — documentation — official documentation for
groff, the typesetting system used to rendermanpages from source
Deepender Yadav is a B.Tech Computer Science Engineering student and software developer interested in building practical software and open-source projects.
GitHub · LinkedInCopy. Stack. Drop.
Transform your clipboard into an interactive edge shelf. Stack, pin, and drag assets into any app with zero friction.
Download for Windows Get from Microsoft Store
How to Install Guide · First 10 Minutes Guide · Drag & Drop Guide · Edge-Drop vs Win+V · Support
Free · Lightweight · Privacy First