Format Kotlin

Format Kotlin source with Elide

elide ktfmt formats Kotlin source with ktfmt.

Format files

elide ktfmt -- Hello.kt src/main/kotlin

A normal invocation rewrites files in place.

Check formatting

Use -n or --dry-run after --. The command exits 1 when a file would change:

elide ktfmt -- -n src/main/kotlin

Elide adds two reporting options before --:

elide ktfmt --list-files -- -n src/main/kotlin
elide ktfmt --list-diffs -- -n src/main/kotlin
elide ktfmt --list-diffs=5 -- -n src/main/kotlin

--list-diffs=N prints diffs only when at most N files fail; otherwise it falls back to listing paths. Use =N, not a separate value.

Argument files can be combined with formatter flags:

elide ktfmt -- --google-style @kotlin-sources.txt

To format Java and Kotlin in one command, use:

elide format -- src