How to convert spaces to tabs
- Paste your code into Input.
- Set Tab width to the number of spaces per indent level in your text, such as 4.
- Copy the result. Each full group of spaces at the start of a line is now one tab.
When you need tabs
- Makefiles, where every recipe line must start with a tab. Spaces give a “missing separator” error.
- Go code, which gofmt indents with tabs.
- Projects whose style guide or
.editorconfigfile setsindent_style = tab. - Pasting code into a file that already uses tabs, so the indentation matches.
Why some people prefer tabs
A tab is one character per indent level, so each person can set the display width they like in their editor without changing the file. Someone who likes deep indentation sees 8 columns, someone on a laptop sees 2, and the file stays the same. The trade-off is that lining things up inside a line, such as a column of comments, only works reliably with spaces. That’s why this tool converts indentation and leaves the rest of each line alone.