Manuscript Documentation
v2026.12.0

Formatting#

Let ms fmt handle spacing and line wrapping so you can focus on the program. Use its check mode before sharing a change to find formatting drift without rewriting files.

Format one file#

Save this valid but unevenly spaced program as format.ms:

text
fn main() Void {
  total:=2+3
  print(total)
}
sh
ms fmt format.ms --check
text
Formatting needed: format.ms; run ms fmt format.ms to rewrite it

The check exits with status 1 and leaves the file unchanged. Apply the formatting, then check again:

sh
ms fmt format.ms
ms fmt format.ms --check

Both commands now succeed silently. The assignment becomes total := 2 + 3; running the program still prints 5.

Format files or a project#

sh
ms fmt file.ms
ms fmt file.ms --check
ms fmt ms.toml --check
ms fmt ms.toml --check --json
ms fmt src test.ms
ms fmt src/*.ms --check
  • Files are rewritten in place, keeping permissions. Invalid source gets diagnostics and is left unchanged; other files still format.
  • --check writes nothing, lists every file needing changes in path order, and returns 1 if any file needs changes or fails.
  • A manifest selects its entry, every .ms file below source, and test.ms/*_test.ms. A directory selects all .ms files recursively.
  • Discovery skips hidden, vendor, and node_modules directories and directory symlinks; file symlinks must stay in the root. Explicit files can select excluded paths. Overlaps format once; an empty directory succeeds.
  • Paths display relative to the invocation directory when inside it, otherwise absolute. See the JSON contract .

Formatter contract#

Formatting preserves meaning and comments, indents with one tab per level and always writes LF endings on every platform, converting CRLF input (ms fmt --check reports a CRLF file as needing formatting), ends with a final newline, and is idempotent. Rules:

  • Keep token spellings; wrap only past 88 columns. Groups that fit stay on one line; wrapped lists pack simple elements into rows.
  • A paragraph of consecutive // prose lines with a line wider than 88 columns is refilled to 88. Lists, indented text, code fences, ms:/manuscript:/conform: lines and trailing comments are left as written.
  • A call or signature that does not fit on one line puts one argument or parameter on each line, with a trailing comma (none after a callback or block body, where a comma would belong to the body). List literals of simple items still fill lines.
  • A flow of three or more stages (a | b? | c?) wider than 50 columns is parenthesized with one stage per line, each starting with |; a line starting with . after a flow step becomes its own | .name(...) stage.
  • Keep single-step blocks beside adjacent work; separate substantial blocks and guards with blank lines, except that a one-line guard directly before the final return of a two-statement body stays together with it. Authored blank lines are discarded, except one kept after a comment-only line so a comment block stays apart from the next comment or declaration.
  • Keep match arms together.
  • Neighbouring fields, parameters and enum payload names with the same type (and default) are joined: width, height Int; a comment or blank line between them keeps them apart.
  • One space around operators and after colons and commas; blocks are braced and indented by nesting depth, so a one-line block is expanded; none next to delimiters; two before inline comments.
  • Drop trailing whitespace and round comment-only indentation down to a multiple of four.

Rewrites are atomic renames in the same directory. Pass --drop-labels to remove redundant call labels (key: key where the parameter binds by position) using the checked program.