How to convert tabs to spaces
- Paste your code or text into Input.
- Pick the Tab width the text was written with, usually 2 or 4 for code.
- Copy the result. Every tab is now spaces, and text after a tab still lines up in the same column.
Why tabs cause trouble
A tab has no fixed width. One editor shows it as 4 columns, another as 8, and terminals, code review tools and email clients all pick their own. Code that looks neatly aligned on your screen can look ragged somewhere else, especially when tabs and spaces are mixed in the same file. Spaces look the same everywhere.
Some formats care even more. Python 3 refuses to run a file that mixes tabs and spaces in an ambiguous way and raises a TabError, and YAML doesn’t allow tabs for indentation at all. Converting the whole file to spaces avoids both problems.
Choosing the tab width
Use the width the text was written with. If you pick a different one, indentation still works, but anything lined up after a tab, such as the comment in the example, will shift. If a file looks wrong after converting, try 8. It’s the traditional terminal default and what many older files assume.