Hi everyone ![]()
I’m using Apple’s swift-format to keep my Swift code tidy, and I’d love to achieve a visual style where there’s one blank line between consecutive components inside a @ViewBuilder — for example:
var body: some View {
VStack {
Text("Hello")
Image(systemName: "star")
Button("Tap") {}
}
}
But without adding newlines at the start or end of the block.
Currently, it seems swift-format doesn’t have a built-in rule or configuration that can insert blank lines between statements, only around declarations or after imports.
Before hacking together a regex post-processor, I wanted to ask:
-
Is there any ongoing work or planned rule in
swift-formatto support spacing between expressions (like ViewBuilder components)? -
Has anyone experimented with custom rule support or an API for registering extra rules at runtime?
-
Would such a feature be acceptable as a contribution (e.g. a
BlankLineBetweenStatementsInViewBuilderrule)?
This kind of spacing makes SwiftUI code far more readable in larger body views, so I imagine others might be interested too.
Thanks in advance for any pointers or design guidance!
— Nick