<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="213703" data-post-id="213703">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Will-W" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Will-W/120/19451_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Will-W
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The formatter downsides that people have pointed out are real but are far outweighed by the benefit of consistent formatting. Consistent both across your project and from project to project. We all have our preferences on style, but you get used to anything after a while and the consistency is a joy.</p>
<p>On my project, I always ensure that one of my pipeline stages runs the following command:</p>
<p><code>mix format --check-formatted</code></p>
<p>This returns a non-zero error code if the formatter would have to change anything to make the code formatted, which keeps our codebase consistent. Team members are then responsible for ensuring that formatting happens as part of their workflow (mostly through format on save in VS Code, but in some cases pre-commit hook, or just remembering).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="213703" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/do-you-use-formatter-in-your-elixir-project/39638/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-213703" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="213703"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #21"></div>
  </section>
</div>
    <div class="postbit" id="213730" data-post-id="213730">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="keathley" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/keathley/120/2652_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  keathley
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’ll also second that if you <em>are</em> going to use the formatter, you should add it to your editor so that you can see what it does on save. That way you can improve its output and ensure your code is still readable. Its not really designed to make code readable by default. Its just enforcing some pretty rough rules and what it generates can be janky if you don’t work on correcting it. Said differently, if your going to use the formatter, running <code>mix format</code> should be considered the first step in formatting your code. Not the last.</p>
<p>Finally, while people talk about consistency, I just need to say that you aren’t a bad person for choosing to not use the formatter, simply because it doesn’t suit your style or output the code in a way that is most readable to you and your team. If your running an open source project you can help signal this to other folks by updating your <code>.formatter.exs</code> file to include an empty list for <code>inputs: []</code>. That way files won’t get churned.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="213730" data-batch-url="/posts/batch_likers">
                        8
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/do-you-use-formatter-in-your-elixir-project/39638/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-213730" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="213730"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #22"></div>
  </section>
</div>
    <div class="postbit" id="213731" data-post-id="213731">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="keathley" data-post="23" data-topic="39638">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/keathley/48/2652_2.png" class="avatar"> keathley:</div>
<blockquote>
<p>Its just enforcing some pretty rough rules and what it generates can be janky if you don’t work on correcting it.</p>
</blockquote>
</aside>
<p>Yeah, Elixir’s formatter can be stricter. For example, if I exceed my line limit (I set it to 95) then the formatter correctly splits the line in two. But if I then change my mind and rename some variables to shorter names, on save the formatter doesn’t collapse those two lines back into one. Which it really should.</p>
<p>Contrast this with Rust’s formatter which is absolutely brutal and will not only reformat your code but also remove things it deems unnecessary, e.g. a single statement in a pattern matching arm that you used curly braces around? Yeah, the formatter removes them because again, it’s a single statement and it’s acceptable for the compiler, and it’s also more terse.</p>
<p>So I’d even venture saying that Elixir’s formatter doesn’t go far enough. I’d love it if it was even more opinionated!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="213731" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/do-you-use-formatter-in-your-elixir-project/39638/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-213731" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="213731"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #23"></div>
  </section>
</div>
    <div class="postbit" id="213765" data-post-id="213765">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Sebb" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Sebb/120/21818_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Sebb
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="dimitarvp" data-post="24" data-topic="39638">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/48/38664_2.png" class="avatar"> dimitarvp:</div>
<blockquote>
<p>Yeah, Elixir’s formatter can be stricter. For example, if I exceed my line limit (I set it to 95) then the formatter correctly splits the line in two. But if I then change my mind and rename some variables to shorter names, on save the formatter doesn’t collapse those two lines back into one. Which it really should.</p>
</blockquote>
</aside>
<p>Fully agree. Another example:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">case number do
  1 -&gt; :one
  2 -&gt; :two
  3 -&gt; :three
  number -&gt; :very_big
end
</code></pre>
<p>add an inspect:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">case number do
  1 -&gt; :one
  2 -&gt; :two
  3 -&gt; :three
  number -&gt;
    IO.inspect(number)
    :very_big
end
</code></pre>
<p>formatter:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">case number do
  1 -&gt;
    :one

  2 -&gt;
    :two

  3 -&gt;
    :three

  number -&gt;
    IO.inspect(number)
    :very_big
end
</code></pre>
<p>thats ok, but its not changed back when the inspect is removed.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="213765" data-batch-url="/posts/batch_likers">
                        5
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/do-you-use-formatter-in-your-elixir-project/39638/25">Post #24</a>
	                </div>
	            </div>
              <div id="likers-container-213765" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="213765"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #24"></div>
  </section>
</div>
    <div class="postbit" id="213780" data-post-id="213780">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="wojtekmach" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wojtekmach/120/999_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  wojtekmach
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Hex Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I personally like using the formatter and I have set up to format on file save. I like that I can write whatever, not caring about spacing etc, and the formatter would do roughly what I’d expect.</p>
<p>I don’t mind at all when other people choose not to use it, it’s their code after all!</p>
<p>I have a small wrapper over <code>mix</code>, <code>m</code>, and <code>m format</code> [1] (which my editor would execute on file save) would skip formatting based on simple heuristics.</p>
<p>[1] <a href="https://github.com/wojtekmach/dotfiles/blob/66cb3c9ff201c26a9173b70d17055ee0711ce9ce/bin/m#L26:L35" class="inline-onebox" rel="noopener nofollow ugc">dotfiles/bin/m at 66cb3c9ff201c26a9173b70d17055ee0711ce9ce · wojtekmach/dotfiles · GitHub</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="213780" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/do-you-use-formatter-in-your-elixir-project/39638/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-213780" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="213780"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #25"></div>
  </section>
</div>
    <div class="postbit" id="213819" data-post-id="213819">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kenny-evitt" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kenny-evitt
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m mostly working on a project that’s (to me) ‘legacy code’ and it’s formatted somewhat inconsistently.</p>
<p>But I think some of my own idiosyncratic preferences are pretty useful (or at least pretty) and formatting code in my own style seems helpful for reading and understanding code as well as being enjoyable to read thereafter.</p>
<p>I didn’t know “tabular code” is a thing (with a name), but that’s a big part of my personal style, in any language. I find it <em>so</em> much more readable than alternatives; so much faster and easier to scan, compare, and even edit.</p>
<p>But I have had some limited use from using the default formatter, mostly just for individual files that have ‘archaic’ formatting. It’s a really helpful base formatting and matches my own preferred style pretty well as-is.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="213819" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/do-you-use-formatter-in-your-elixir-project/39638/27">Post #26</a>
	                </div>
	            </div>
              <div id="likers-container-213819" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="213819"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #26"></div>
  </section>
</div>
    <div class="postbit" id="213840" data-post-id="213840">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="BartOtten" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/BartOtten/120/25440_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  BartOtten
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>How I would love Elixir to not touch ‘with’ statements (or apply tabular formatting!) They allow such readable code…until the formatter kicks in and makes the flow hard to follow <img src="https://forum.elixirforum.com/images/emoji/apple/frowning.png?v=15" title=":frowning:" class="emoji" alt=":frowning:" loading="lazy" width="20" height="20"></p>
<p>It’s probably my only beef with it.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="213840" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/do-you-use-formatter-in-your-elixir-project/39638/28">Post #27</a>
	                </div>
	            </div>
              <div id="likers-container-213840" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="213840"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #27"></div>
  </section>
</div>
    <div class="postbit" id="213969" data-post-id="213969">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="zookzook" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zookzook/120/15276_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  zookzook
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I don’t like formatter at all. I can understand, that the code is more consistency, so everybody can “read” it. On the other hand, I like to have my own style (tabular code). After all, I am the author of the code and you can see that there. I write this code and have been doing so since 1984, before anyone formatted the code. So when I program, I want to write good code that works effectively and whose logical relationships can be read in the program sequence. With comments in the places that are important (the elixir formatter moves my comments, arrg!).</p>
<p>I started on one project and didn’t call “mix format” on commit, then I was told by four other developers to call “mix format” even when there were already three such comments to read. In the end, everything was nicely formatted, but the application totally failed. And none of these developers was able to solve the problems of the application, although now with the formatted code all developers can read the code so easily <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>In other words, mix format does not help to write good code.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="213969" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/do-you-use-formatter-in-your-elixir-project/39638/29">Post #28</a>
	                </div>
	            </div>
              <div id="likers-container-213969" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="213969"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #28"></div>
  </section>
</div>
    <div class="postbit" id="213981" data-post-id="213981">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="zookzook" data-post="29" data-topic="39638">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zookzook/48/15276_2.png" class="avatar"> zookzook:</div>
<blockquote>
<p>In other words, mix format does not help to write good code.</p>
</blockquote>
</aside>
<p>Nobody is claiming that it does. It’s a measure for team-wide consistency, nothing more.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="213981" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/do-you-use-formatter-in-your-elixir-project/39638/30">Post #29</a>
	                </div>
	            </div>
              <div id="likers-container-213981" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="213981"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #29"></div>
  </section>
</div>
    <div class="postbit" id="214015" data-post-id="214015">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dmitrykleymenov" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dmitrykleymenov/120/40039_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dmitrykleymenov
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<blockquote>
<p>In other words, mix format does not help to write good code.</p>
</blockquote>
<p>Depends on what you are meaning by “good code”. If you write alone, nobody sees your code, so yeah, it won’t help to write better code. Nobody will get advantages from the systematization. But if other people read and try to understand your code, familiar syntax will help a lot. And it is worth nothing to say, that to understand another person code is much harder than your own, so in my opinion <em><strong>EVERYONE SHOULD TRY TO HELP TO DO THAT</strong></em> in any way it’s possible. As i said earlier, as longer i use it, as much more i like it. And for me formatter main goal is not to write good code for my self(it helps widely though), but for other people to do common work easy, not only my own.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="214015" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/do-you-use-formatter-in-your-elixir-project/39638/31">Post #30</a>
	                </div>
	            </div>
              <div id="likers-container-214015" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="214015"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #30"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/39638/load_more?page=4">Load more posts (11 remaining)</a>
</div></template></turbo-stream>