BASM-FMT Examples
Basic Formatting
Given:
produces:
Rewriting Files In Place
Each file that would change is rewritten; a file that's already correctly formatted is left untouched (not touched on disk at all, so timestamps/watchers aren't disturbed for no reason).
Checking Formatting in CI
Writes nothing. Exits 0 if every file is already formatted, or 1 and prints
<path>: would be reformatted for each file that isn't - a typical CI gate.
Previewing Changes
(shown here without the terminal color codes basm-fmt actually prints)
Formatting Only a Line Range
Useful for formatting just the lines a patch touched, leaving the rest of a large file exactly as it was:
Given:
only line 2 changes:
Case Style
--mnemonic-case, --directive-case and --register-case are independent: setting only
the first two leaves register names (AF, HL, ...) at their default (uppercase).
Numeric Literal Style
turns &4000 / 0FFFFh into 0x4000 / 0xFFFF.
Comma and Quote Style
turns db 1,2,3 into DB 1, 2, 3, and db "hello" into DB 'hello' (a literal that
contains the target quote character, like "it's here", is left untouched rather than
converted into something that would need an escape).
Collapsing Blank Lines
collapses any run of more than one consecutive blank line down to exactly one.
Preserving Hand-Laid-Out Code
The region between the markers is passed through completely unchanged; code before and after it is still formatted normally.
Using a Config File
basm-fmt.toml, in the project root or any ancestor directory:
basm-fmt src/*.asm # picks up basm-fmt.toml automatically
basm-fmt --indent-size 4 src/*.asm # the flag wins over the config file for this run
See Also
- Overview - Features and quick start
- Command Line Reference - Complete option reference
- BASM - The assembler this formatter targets