Skip to content

Format MiniZinc files

Terminal window
# Print formatted source to stdout.
zincite fmt model.mzn
# Check files or a directory without changing them.
zincite fmt --check model.mzn data.dzn
zincite fmt --check models/
# Format explicit files in place.
zincite fmt --write model.mzn data.dzn

With no input argument, or with -, the formatter reads stdin. Multiple files require --check or --write; directories support --check only. Directory checks include hidden and Git-ignored .mzn and .dzn files and skip .git.

See the formatting style gallery for the settled layout rules and reproducible examples.

Syntax or formatting-directive errors leave the affected file untouched. --write preserves file permissions and refuses symlinks. Other independent files are still processed when one fails.

Use the format-on-save recipe for stdin invocation, buffer replacement and failure handling. The support page describes the current interactive acceptance limit.

The formatter reads .editorconfig files. For example:

root = true
[*.{mzn,dzn}]
indent_style = space
indent_size = 4
max_line_length = 120
end_of_line = lf
insert_final_newline = true

It also supports tab_width, trim_trailing_whitespace and charset (utf-8 or utf-8-bom). Set max_line_length = off to disable width-based wrapping. Comments, literal contents and skipped regions retain their original text.

Command-line options override EditorConfig:

Terminal window
zincite fmt --indent-size 2 --max-line-length 80 model.mzn

Run zincite fmt --help (or zincite-fmt --help) for all options.

Use the formatting directive examples to preserve a complete item or region. The formatter reference defines protected ranges and invalid marker placement.

See the command reference for exit codes and the formatter library reference for Rust use.