Apexfmt formats Apex code. It uses tabs for indentation.
Given a file, it writes the formatted code to standard output by default. The
--write
/-w
flag can be used to overwrite the original file(s). The
--list
/-l
flag can be used to list files with formatting different from
apexfmt's.
$ apexfmt -w sfdx/main/default/classes/*.cls sfdx/main/default/triggers/*.trigger
apexfmt is included as a default formatter in vim-autoformat.
Try out apexfmt in a browser at https://apexfmt.octoberswimmer.com/.
apexfmt is inspired by gofmt.
The antlr4 grammar is based on the @nawforce's apex-parser grammar, which is originally based on the grammer used by @neowit's tooling-force.com.
apexfmt in the browser forked from go-fmt-wasm.