Remove extra spaces
Paste text: double spaces become one, and spaces at line ends go.
What does it do to a real text?
A bill line with double spaces, a no-break space and a tab:
Before
Total amount:NBSP₹ 4,500⏎
tabDue on 10 May
After
Total amount: ₹ 4,500⏎
Due on 10 May
Fixed 1 odd space, 1 tab, 2 line ends and 2 double spaces.
⏎ marks a line break, and a short name in a box a hidden character.
What rules does it follow?
- Two or more spaces in a row become one.
The other 5 rules
- Spaces at line ends removed: spaces at the start and at the end of every line go.
- Tabs made a space: each tab becomes one space, and runs of spaces then fold to one.
- Odd spaces made plain: the no-break space (U+00A0), narrow no-break space (U+202F), medium mathematical space (U+205F), ideographic space (U+3000), ogham space mark (U+1680), and the spaces from U+2000 to U+200A each become a plain space source.
- Runs of blank lines closed up (off at the start): three or more line breaks in a row become one empty line, and empty lines at the start and end go.
- Line breaks are never removed here; to join lines, use Remove line breaks.
What do people ask?
Why does a space survive Excel’s TRIM?
TRIM leaves single spaces between words and removes the rest source, but it was made for the plain space, number 32; the no-break space, number 160, stays source. Turn it into a plain space with SUBSTITUTE first source. In cell A2, which holds a space, Total, a no-break space, a space, amount and a space:
| Formula | Result |
|---|---|
=TRIM(A2) | TotalNBSP amount |
=TRIM(SUBSTITUTE(A2,CHAR(160)," ")) | Total amount |
The first result still holds the no-break space (NBSP); the second is clean.
Does it remove the space before a full stop?
No. A single space before punctuation is left as it is.
Why is there a gap I cannot delete?
It may not be a space at all: the braille pattern blank looks like one source. Remove invisible characters finds it.