How to Copy man Page and --help Text Without Line Breaks
The line breaks you get when copying from man or --help aren't added by the copy. The program inserted them before printing, by wrapping its text to fit the terminal (or to a fixed width), so the terminal has nothing to undo. Either make the program render wider before you copy (MANWIDTH for man pages, Out-String -Width for PowerShell help), or copy the text as it is and join the lines afterwards.
Why the line breaks are real
man formats each page for a line length before it reaches your screen. With man-db, the usual man on Linux and in WSL distributions, that length comes from the MANWIDTH variable if set, otherwise from the terminal width, falling back to 80 columns. Each formatted line ends in a real newline.
--help text is usually written with line breaks already in it. GNU tools print fixed help text whatever the window size. PowerShell's Get-Help formats its output to the console width. In every case the newlines are part of the output, so copying preserves them faithfully.
man pages: render wider, then copy
In WSL or another Linux shell, set MANWIDTH for a single command and send the result to a file:
MANWIDTH=1000 man grep > grep.txt
MANWIDTH=1000makes each paragraph one long line.- When output goes to a file or a pipe, man-db drops the bold and underline formatting characters, so the file holds plain text.
- Writing to a file avoids encoding problems with the clipboard. Open it from WSL with
notepad.exe grep.txtorcode grep.txtand copy what you need.
If you copy man pages often, add export MANWIDTH=1000 to ~/.bashrc. Pages then show long lines in the terminal too, so you may prefer to set it only when copying. WSL clipboard: what crosses into Windows covers sending text straight from WSL to the Windows clipboard.
PowerShell help: widen the output
Out-String -Width controls the line length PowerShell formats to, and Set-Clipboard puts the result on the clipboard:
Get-Help Get-ChildItem -Full | Out-String -Width 300 | Set-Clipboard
Paragraphs that fit within 300 characters come out as single lines. Microsoft's own docs page for any cmdlet is often easier to copy from; Get-Help Get-ChildItem -Online opens it in your browser.
--help for other programs
- Python tools built with
argparse: they size help to the terminal width reported byshutil.get_terminal_size(), which checks theCOLUMNSenvironment variable first. In bash, runCOLUMNS=200 mytool --help. In PowerShell, set$env:COLUMNS = 200, run the command, thenRemove-Item Env:COLUMNS. - GNU coreutils and most compiled tools: the help text has fixed line breaks, so
COLUMNSchanges nothing. Join the lines after copying instead. - Windows commands (
dir /?,robocopy /?): also fixed. In Command Prompt,dir /? | clipcopies the whole text without selecting anything.
Join the lines after copying
When you can't render wider, fix the text afterwards. Copy only the paragraph you need, because joining a whole page merges option lists into one block.
With PowerShell
This joins every line break that sits inside a paragraph and keeps blank lines between paragraphs. It also removes the indentation from the start of each joined line:
(Get-Clipboard -Raw) -replace '(?<=\S)[ \t]*\r?\n[ \t]*(?=\S)', ' ' | Set-Clipboard
Run it, then paste. The PowerShell clipboard cheat sheet has more clipboard one-liners.
With VS Code
- Paste the text into a new file (Ctrl+N, Ctrl+V).
- Select the lines that belong to one paragraph.
- Open the Command Palette (Ctrl+Shift+P) and run Join Lines.
The same fix works for text copied out of PDFs, which break lines the same way; how to copy from a PDF without broken line breaks covers that case.
When to keep the line breaks
Option lists, usage synopses and examples read better with their original layout. Git commit messages are another case where the wrapping is deliberate; copying a commit message with its line breaks covers the 50/72 convention. When you paste those into Slack, Teams, GitHub or a Markdown file, put them in a code block (three backticks before and after) so the destination keeps the alignment. How to keep line breaks when pasting into Slack explains how Slack treats pasted text. If the copied text arrives with odd symbols or colour codes instead, see how to copy from Windows Terminal without garbled text.
FAQ
Does widening the terminal window fix it?
For man, yes, if you widen the window before running man, since it reads the width at that moment. For GNU --help text, no; its line breaks are fixed.
Why does a saved man page show doubled letters or ^H characters?
Those are the backspace sequences man uses for bold and underline. man-db normally removes them when output goes to a file, but keeps them if MAN_KEEP_FORMATTING is set. Pipe the output through col -b to strip them.
Can you copy a man page without opening WSL?
Not with man itself, which isn't part of Windows. The Linux man-pages project publishes pages online, and for Windows commands, Microsoft Learn has the same help as web pages.
Related reading
- How to Copy Text From a PDF Without Line Breaks
- Windows Terminal: Copy Plain Text Without Formatting
- PowerShell Clipboard Cheat Sheet: Get-Clipboard and Set-Clipboard
- WSL Clipboard: Copy and Paste Between Linux and Windows
Sources
- man(1) (Linux manual page) —
MANWIDTH, the 80-column fallback, andMAN_KEEP_FORMATTING. - col(1) (Linux manual page) —
-bremoves backspaces. - Out-String (Microsoft Learn) —
-Widthsets the line length of formatted output. - Set-Clipboard (Microsoft Learn) — sending text to the clipboard.
- Get-Clipboard (Microsoft Learn) —
-Rawreturns one string. - shutil.get_terminal_size (Python docs) — checks the
COLUMNSenvironment variable. - Working across file systems (Microsoft Learn) — running Windows tools such as
notepad.exefrom WSL.
Deepender Yadav created Edge Drop and builds and tests it, from the edge-hover shelf to each release. A B.Tech Computer Science Engineering student, Deepender writes the Edge Drop guides, comparisons and developer posts, and checks product details against the app's source code.
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