DEV Community

Discussion on: Use Tabs For Indentation

Collapse
moopet profile image
Ben Sinclair

I understand what accessibility means, I also understand what was written in the post. What I'm saying is that presentation of the code is the responsibility of the IDE - it already will allow you to specify tab widths, it should understand indentation widths and do the transformation automatically.

IDEs already do this with things like line endings. The accessibility problem is in the software not the format of the file.

Thread Thread
louy2 profile image
Yufan Lou Author

Let's go through what the workflow of someone who needs to transform the file from tab to space might look like:

  1. They clone the repo
  2. They open the file in their editor of choice, which transforms the file to their preferred indentation width
  3. They do their changes
  4. They save their changes along with the new indentation width
  5. They transform the file to the indentation width preferred by the project
  6. They commit their changes back to the repo

Problems:

  • Step 2 and 5 might be erroneous, adding one step following them
  • I have not seen IDE do step 5 automatically, maybe because it may be erroneous

What does the workflow look like if the project uses tab?

  1. They clone the repo
  2. They open the file in their editor of choice, displayed in their preferred indentation width
  3. They do their changes
  4. They save the file
  5. They commit their changes back to repo

Indentation width of every developer of the repo is respected, without transformation.

I do not have a strong personal preference to tab over space, nor to a specific indentation width. But I have a strong preference to protecting the marginalized people and fairness. A project-wise indentation width can be formatted with either tab or space. Formatting with space incurs more work for those in need of a different width than not. Formatting with tab incurs the same amount of work for everyone regardless of which width they need.

I agree that IDE can help. An IDE which maintains both the user preference and the project preference and can transform between the two is probably sufficient for 90% of the use cases. But that's not 100%, and does not change the essence that formatting the indentation width with space ends up being not as fair as with tab.

Thread Thread
moopet profile image
Ben Sinclair

What's the 10% of cases where automatically formatting the document isn't sufficient?

Thread Thread
louy2 profile image
Yufan Lou Author

I don't know yet. Right now such IDE capable of auto-converting formatting don't exist to my knowledge so they cover 0% of the cases. If I find IDE plugins with such feature out in the wild, then I can know what cases they do not cover from user comments.