Hi everyone! I’d like to share ExAlign, a new Mix formatter plugin that adds
gofmt style column alignment on top of the standard Elixir formatter.
It’s aimed at having better code readability compared to the standard “opinionated” formatter. There is no claim that one is better than another - code formatting has always been a matter of a personal taste.
Source code: https://github.com/saleyn/exalign
Documentation: https://hexdocs.pm/exalign
What it does
ExAlign runs as a formatter plugin pass after Code.format_string!, so you keep
all standard Elixir style rules and get vertical alignment layered on top. It aligns
consecutive lines that share the same indentation and pattern:
Keyword lists / struct fields
%User{
name: "Alice",
age: 30,
occupation: "developer"
}
Variable assignments
x = 1
foo = "bar"
something_long = 42
Module attributes
@name “Alice”
@version “1.0.0”
@default_timeout 5_000
Macro calls (e.g. Ecto schema fields, NimbleCSV field definitions)
field :reservation_code, function: &extract_reservation_code/1
field :guest_name, function: &extract_guest_name/1
field :check_in_date, function: &extract_check_in_date/1
Macro names are auto-detected - no manual locals_without_parens config needed
for aligned groups.
Arrow-clause collapsing - short -> arms are collapsed back to one line when
they fit within line_length:
case result do
{:ok, value} -> value
{:error, _} = err -> err
end
Standalone CLI
There’s also a self-contained exalign escript (no Mix project needed) available
on the GitHub releases page
Feedback and contributions very welcome! The contribution guide requires a fixture
pair (input + expected output) alongside any formatting behavior change, which keeps
the test suite honest.






















