Clean Terminal Output
By Ripple Software — ripple-software.com
Clean Terminal Output strips terminal-cell whitespace out of text you have copied to
the clipboard. It is built for the case where you select and copy text from a
terminal using the review cursor and end up with trailing spaces on every line,
"blank" lines that are actually full of spaces, and leading indentation you did
not want.
How to use it
- Copy the messy text however you normally do. For terminal text, that is
usually the review cursor: NVDA+f9 to mark the start, move to the end, then
NVDA+f10 to copy the selection.
- Press NVDA+Shift+C. The clipboard is cleaned in place and you
will hear "Clipboard cleaned."
- Paste anywhere with Ctrl+V. The text is now flush left, with no trailing
spaces and no spaced-out blank lines.
What it does to the text
- Trims leading and trailing whitespace from every line, so each line is flush
left with no trailing runway of spaces.
- Turns lines that were only spaces into genuinely empty lines.
- Collapses runs of three or more blank lines down to a single blank line.
- Removes blank lines from the very top and bottom of the copied block.
Settings
Open NVDA's Settings dialog (NVDA menu, Preferences, Settings) and choose the
Clean Terminal Output category. You can configure:
- Left indentation — how leading whitespace is handled:
- Flush left (default): every line has all leading spaces removed.
Best for prose.
- Strip shared margin only: removes the common left margin but keeps
relative indentation, so code blocks and nested lists keep their structure.
- Leave leading spaces alone: only trailing whitespace and spaced-out
blank lines are cleaned; indentation is untouched.
- Collapse runs of blank lines (default on): turns three or
more consecutive blank lines into a single blank line. Turn off to keep the
original spacing.
- Speak a confirmation after cleaning (default on): when off,
successful cleans happen silently. Error messages (empty clipboard, no text)
always speak regardless of this setting.
Changing the shortcut
The default gesture is NVDA+Shift+C. To change it, open NVDA's Input Gestures
dialog (NVDA menu, Preferences, Input Gestures), expand the "Clean Terminal Output"
category, and rebind the "Cleans whitespace from the text on the clipboard"
command to whatever key you prefer.