Closed wisonye closed 1 year ago
@wisonye The answer is to use a trailing comma when you want each element on a separate line.
Without a comma after baz
, zig fmt produces this:
.{ foo, bar, baz }
With a comma after baz
, zig fmt produces this:
.{
foo,
bar,
baz,
}
I personally think this is very clever and I like it, but you have to know the trick!
@wisonye The answer is to use a trailing comma when you want each element on a separate line.
Without a comma after
baz
, zig fmt produces this:.{ foo, bar, baz }
With a comma after
baz
, zig fmt produces this:.{ foo, bar, baz, }
I personally think this is very clever and I like it, but you have to know the trick!
Yup thanks, actually I got the answer already from the Zig discord, just forgot to close this issue, thanks anyway :)
Love this plugin except for one thing I hope to be solved:
I found that each statement is always a single line after formatted:
Is that possible
zig fmt
can accept the following style result by whatever options? As I think that's important for using vertical split in Laptop screen size to edit 2 source files at the same time:)For example, this is the formatted result after I copy&paste into
C
file, it looks much better than a long long single line:I mean at least have an optional configuration file for
zig fmt
? (enable or disable part of the format rather than encapsulate all format policies inside and can't change?)Sorry, I'm new to
zig
, love to learn more:)