Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Formatting

bitterasm format (or fmt) rewrites .basm files in a consistent style:

bitterasm format program.basm     # one file
bitterasm fmt std/                # every .basm file below a directory
bitterasm format --check .        # change nothing; fail if anything would change

--check is meant for CI: it exits with a non-zero status if any file isn’t formatted.

What it changes

  • Indentation, following (), [] and {}, plus one level for the lines under a top-level label.
  • Facets, each moved to its own indented line.
  • Trailing whitespace, runs of blank lines, and the final newline.
  • Comments longer than comment_width, which are wrapped. In doc comments, code blocks, tables and headings are left as written.
  • Long lines, which are wrapped at commas inside (), [] and {}. A line with no such comma stays long, since a newline would end the statement.

It keeps every comment and never changes what the code means.

Configuration

The formatter reads bitterasm.toml (or .bitterasm.toml), searching the file’s directory and then its parents, like rustfmt. Pass --config path/to/bitterasm.toml to choose one. Every setting is optional:

SettingDefaultMeaning
indent_width4Spaces per indentation level.
hard_tabsfalseIndent with tabs instead of spaces.
indent_facetstrueIndent | facet lines one level under their declaration.
facets_on_new_linetrueMove facets written on the declaration’s line onto their own lines.
indent_label_bodiestrueIndent the lines under a top-level label, up to the next label, section or declaration.
pub_on_declarationtrueRewrite an old-style | pub line as pub on the declaration.
return_type_on_declarationtrueRewrite an old-style | -> T line as -> T on the declaration.
collapse_short_multiline_genericstrueJoin a generic argument list that was split across lines back onto one, when it fits.
max_blank_lines1The most consecutive blank lines kept.
max_width100The line width code is wrapped at.
comment_width80The line width comments are wrapped at.
newline_style"Auto""Auto", "Unix" or "Windows" line endings.
indent_width = 2
max_width = 90

The same file holds lint settings, under [lints].