My product list indents sub-items; how do I clean double spaces without losing that indentation?
Untick 'Trim whitespace at the start of each line' and keep 'Collapse repeated spaces into one' ticked. Collapsing is built to leave the start of a line alone and only work after the first visible character, so the indentation stays while double spaces between words go. With the default rules the indentation is lost, because start trimming is on.
Example: a two-level list
A list you wrote in a note: the heading 'Products:' with two items under it indented by four spaces, and some double spaces between words that came in from copying.
Line 1 is 'Products:', then 'Arabic', three spaces and 'coffee' indented by four spaces, then 'Green', four spaces and 'tea' with the same indent.
With the default rules: 4 changes, the start of 2 lines trimmed and 2 runs collapsed. The indent disappears and both items sit level with the heading.
With start trimming off: only 2 changes, 2 runs collapsed. Both items keep their four-space indent and read 'Arabic coffee' and 'Green tea' with a single space.
Steps
- Open the Whitespace cleaner and paste the list.
- Untick 'Trim whitespace at the start of each line'.
- Keep 'Trim whitespace at the end of each line' and 'Collapse repeated spaces into one' ticked.
- Turn on 'Show invisible characters in the preview' and check that the dots at the start of the sub-items are still there.
- Copy the result or apply it to the input.
If the indentation is made of tabs
Some programs indent with a tab rather than spaces. Here too the indent survives with start trimming off: we tried a line starting with a tab, then 'Arabic', three spaces and 'coffee', and the tab stayed at the start while the three spaces were collapsed.
Be careful if you also tick 'Convert tabs to spaces': conversion runs before collapsing, so a leading tab becomes spaces, and the indent survives because collapsing leaves the start of the line alone. A tab between two words, however, becomes spaces and is then collapsed into one.
What else can change the list's shape
- Blank lines between groups are collapsed to one by default. Choose 'Keep them as they are' if the spacing is deliberate.
- A non-breaking space at the start of a line becomes a normal space, and the indent keeps its width.
- A numbered list with two spaces after the number, such as '1. coffee', has that gap collapsed to one space, since the spaces come after the first visible character.
Remember that the cleaner does not understand indentation or add it. It simply leaves it alone when you ask, so if the original indent was uneven, three spaces on one line and five on another, it stays uneven.
Common questions
Does the tool ever collapse the indent spaces themselves?
No, spaces before the first visible character are never collapsed; only the start-trimming rule removes them.
Can I use this on code?
Yes, with start trimming off the indentation stays, but collapsing still affects spaces inside a line, so check the preview if the code relies on them.
Does my text change before I press apply?
No, you see the preview first.
