nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.87k stars 637 forks source link

Indent rule default? #1557

Closed simon-assistiq closed 11 months ago

simon-assistiq commented 11 months ago

Possibly stupid question but I'm just curious. The Rules.md file doesn't specify a default indent. Is there one? When you run swiftformat . without specifying indent it does seem to leave the indents in my project unchanged (4 spaces)… is it actually defaulting to 4 or is it figuring out the indent dynamically? Tried a quick search in the code but it wasn't clear to me.

nicklockwood commented 11 months ago

It's listed under the options for the rule, see the --indent option. If you want 2 spaces use --indent 2

simon-assistiq commented 11 months ago

This is what I'm seeing

image

Where does it say what the default is? Or am I looking in the wrong file?

nicklockwood commented 11 months ago

The default is 4 spaces.

nicklockwood commented 11 months ago

You can use the --inferoptions command to generate a set of defaults from your project, but that's slow, so it doesn't run every time automatically.

simon-assistiq commented 11 months ago

Thanks