← Back to Blog

Developers & Code | Published Aug 21, 2026 | Updated Oct 13, 2026 | 6 min read

How to Copy man Page and --help Text Without Line Breaks

By Deepender Yadav

How to Copy man Page and --help Text Without Line Breaks — Edge Drop Guide

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=1000 makes 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.txt or code grep.txt and 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 by shutil.get_terminal_size(), which checks the COLUMNS environment variable first. In bash, run COLUMNS=200 mytool --help. In PowerShell, set $env:COLUMNS = 200, run the command, then Remove-Item Env:COLUMNS.
  • GNU coreutils and most compiled tools: the help text has fixed line breaks, so COLUMNS changes nothing. Join the lines after copying instead.
  • Windows commands (dir /?, robocopy /?): also fixed. In Command Prompt, dir /? | clip copies 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

  1. Paste the text into a new file (Ctrl+N, Ctrl+V).
  2. Select the lines that belong to one paragraph.
  3. 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

Sources

Deepender Yadav
Written by Deepender Yadav · Creator & Developer

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 · LinkedIn

Copy. 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
Find us on CodeHype