Formatter: consider using tabs instead of spaces #3633
Replies: 9 comments 16 replies
-
|
Do we have any information on the accessibility concerns relating to tabs and spaces? |
Beta Was this translation helpful? Give feedback.
-
|
The downside to this is an increase in perceived strangeness of Gleam. Tabs are unpopular and 8 space tabs even more so, so adopting these will result in fewer people deciding to try Gleam, hurting our growth. Is there anything we can do to avoid GitHub etc showing Gleam with 8 space tabs? |
Beta Was this translation helpful? Give feedback.
-
|
Hi, just wanted to chime in that I am one of the people for whom this accessibility is a thing. 2-space indents makes it nigh-impossible to me to separate scopes. In space-obligatory languages I will use 8 space indents which (as was already pointed out) is a bad choice for many people and tabs are the only solution I know of to address this in a flexible enough way. As for the specifics, I would recommned trying to reformat some larger codebases and identify issues that look weird (sometimes a few linebreaks might be a better way) As for "legacy-support" I see a relatively simple option:
While not a great fan of keeping two modes around, I think the value of tabs is worth it. I am biased though, I will freely admit that. TL;DR: I have yet to find a case where indentation with tabs and aligning with spaces does not work as well, if not better than space-indentation. Also +1 for editorconfig. |
Beta Was this translation helpful? Give feedback.
-
|
Allowing an option in the gleam.toml file would be cool so that people who prefer tabs > spacing . Something like spacing="tab" . |
Beta Was this translation helpful? Give feedback.
-
|
Looks like this was opened 1 year ago. I don't have preference of tabs or spaces, I just want to be able to easily distinguish what code block a line belongs to. Currently with two spaces that requires some squinting on my part.
Basically every language allows whitespace configuration. If anything I would think that not having a config for it deters more people from using the language due to potential eyesight trouble. |
Beta Was this translation helpful? Give feedback.
-
|
As a quick fix so that I can read where blocks are, I made a fork that changes the indent size to 4 spaces rather than 2. The language seems great now that I can see where blocks are! |
Beta Was this translation helpful? Give feedback.
-
|
For me, readability is one of the most important aspects of any language — often it’s even the reason people give a new one a try. What I really like about Gleam is that the formatter isn’t customizable. It enforces a consistent style, which already makes code much easier to read. But readability also depends on your editor — even small details like spacing (tabs, in this case) can make a difference. That’s why I think tabs are the best fit for Gleam: everyone can adjust the spacing to their own preference, while the code itself stays consistent. This is also valuable for people with visual impairments, who might need larger spacing to make code easier to follow on screen. Edit: I wrote this with a little help from AI, as english isn't my native language. I hope you don't mind. |
Beta Was this translation helpful? Give feedback.
-
|
For people using Emacs: a working, but preliminary version of tbindent-mode allowing seamless conversion between space-based indentation to/from tabs-based indentation might provide a useful work-around. This is not yet elpa compliant. That's my next step for this. Any feedback would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
|
hi, also just chiming in that this is one of the things that are majorly annoying me about gleam. i tried to change this via editorconfig, and the formatter is now clashing with my editor (which, correctly, inserts tabs which then get reverted to unreadability on save) even if not officially configurable, the formatter should still respect the editorconfig. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
From time to time someone in the Gleam Discord suggests the formatter could use tabs instead of spaces for accessibility reasons.
A couple of things that have emerged so far:
I've opened this discussion so people can chime in here if they have anything to add or any experience they'd like to share :)
Beta Was this translation helpful? Give feedback.
All reactions