Indentation/TabWidth as Encoding, not style



I don’t know if anyone else would agree with me, but I’m ultimately frustrated by indentation and tab width being treated as “coding style”, when to be perfectly honest, it’s an encoding issue.

If a project prefers files to be saved such that indentation takes the form of 2 spaces, then that’s fine. If another project prefers files to be saved such that indentation is a single tab, that’s also fine. But I want that indentation to display, for all projects, to my preference, and that is a single tab that is 4 spaces width.

I’ve not seen ANY editor do this yet, and maybe there is one I don’t know of. But it would be absolutely great if Atom IO could distinguish between encoding and display preference. Much like I can choose syntax highlighting, font style and inline suggestions etc. we should be able to choose how indentation is displayed, without it affecting the way the file is encoded. If my colleagues want font size 72, yellow, bold and indentation size of 4, I would rather not :smile:

What are people’s thoughts on this?

Feature wise, it would likely mean the Settings only has an “indentation width” - and then separate settings for default encoding as “indentation encoding: tab/spaces” “indentation encoding spaces: 2/4”. These can then be changeable in the status bar for specific files - maybe stored in extended attributes etc. It could be up to plugins to then detect what the encoding should be. But ultimately, to me, it would display my way.


I think you’d be interested in the Elastic Tabstops proposed feature:

This topic isn’t exactly a duplicate, but perhaps your intent is something very similar if not the same?


Ah that looks really interesting and I would be interested in that.

However, my intent was just to handle how indentation should be stored in a file (as tab or spaces). Elastic Tabstops is a good complimentary idea and follows along with my belief that the stored tab (or spaces) should not dictate presentation and the editor should be able to decide how to display it (involving user preferences if required.)

But definitely for indentation, we need to be able to select how those indents are encoded, to allow the saved file to remain visible in tools that don’t understand presentation and instead simply show raw data.


And that is my issue with the Elastic Tabstops idea as well and where I think a lot of this kind of thing falls down :cry: There is just so much tradition and convention around code being completely raw text that anything that doesn’t allow for that is doomed to failure.

Decoupling Display Format From Storage Format

This is where I tried to put together my thoughts on a possible solution … not just around tabs, but around all code formatting:


Just looking at your first example, that is the ABSOLUTE dream and where Editors should aim to be. To completely separate coding style from encoding style.

I think to get this done with indentation first is my main preference and a good baby step in the right direction to appreciating this important distinction, and potentially increasing productivity for everyone. I mean how much time do we waste messing with tabs/spaces in indentation! :slight_smile: