Collapse repeated spaces and tabs
Shrinks runs of spaces and tabs down to a single space.
Example
- Options used
- Default options
Input
Name Age City
Kim ⇥ 34 SeoulOutput
Name Age City Kim 34 Seoul
Symbols in examples: ⇥ tab · · trailing space · ⍽ NBSP · □ full-width space · ◌ zero-width character
Open this operation in the toolWhat it does
Replaces any run of two or more spaces within a line with a single space. By default, tabs are treated as spaces too and become a single space. Line breaks are not touched, so the line structure stays the same.
Options
- Merge tabs into spaces too: turn this off to merge only spaces and leave tabs alone. Turn it off when you need to keep tab-separated table data.
- Keep leading indentation: leaves the spaces and tabs at the start of a line alone and collapses spaces only after them. Use it for lists or code whose hierarchy is expressed by indentation.
When to use it
Text copied from a PDF or scanned document often has several spaces between words because of justified alignment. Text copied from web tables and logs padded to a fixed width behave the same way. Irregular numbers of spaces make searching, replacing and comparing difficult, so unifying them to one space first makes the later steps more reliable.
When tabs are column separators, as in data copied from Excel, and you want to turn tabs into commas, use Find and replace to find \t instead of this operation.