beepboop
Why does the Elixir formatter default to 98 characters?
Why was 98 chosen as the magic number? I can’t find any reference or explanation for it. Usually I see 80, 100 or 120 as the preferred line lengths in other languages.
Marked As Solved
josevalim
The formatter breaks when it is possible to find a break. This is usually always possible but in many cases it cannot, such as a large double quoted string.
Another common scenario is with “do”. If all you have after the line limit is “do”, then there is no opportunity for a break before, so we effectively go line_length+2. Making it 98 means this common case fits exactly 100.
Also Liked
BartOtten
Just for a moment I thought this topic was an April’s Fool joke
Being serious doen’t take the smile away. Thanks both of you
beepboop
I did a couple of manual tests earlier and found that I can create a line with a length of 101, if the formatter is set to line_length: 98. With the setting at 97, it breaks cleanly at 100. Not that it matters much.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









