Skip to content

Latest commit

 

History

202 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

Installation

On macOS and Linux, apexfmt can be installed with Homebrew:

$ brew install octoberswimmer/tap/apexfmt

Pre-built binaries for Linux, macOS, and Windows are also available on the releases page.

Usage

CLI

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

apexfmt sets the Go garbage collector target to 200 unless the GOGC environment variable is set, which cuts the CPU time spent formatting by about a third. Peak memory rises when many files are formatted at once; set GOGC=100 to restore the runtime default.

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

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.

About

Format Apex Code

Resources

Stars

7 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages