Skip to content

octoberswimmer/apexfmt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3fa0e15 · Jan 28, 2025
Dec 5, 2023
Jan 15, 2024
Dec 16, 2024
Dec 18, 2023
Jan 28, 2025
Jan 7, 2025
Jan 7, 2025
Sep 25, 2024
Dec 5, 2023
Nov 27, 2024
Jan 8, 2025
Jan 8, 2025
Dec 1, 2023

Repository files navigation

apexfmt

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.

Usage

CLI

$ apexfmt -w sfdx/main/default/classes/*.cls sfdx/main/default/triggers/*.trigger

Vim

apexfmt is included as a default formatter in vim-autoformat.

Use the following settings to display parse errors and disable the default formatting if apexfmt fails:

let g:autoformat_verbosemode=1
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
let g:autoformat_remove_trailing_spaces = 0

Demo

Try out apexfmt in a browser at https://apexfmt.octoberswimmer.com/.

Thanks

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.