Format MiniZinc files
Use the formatter to give models a consistent layout while keeping comments, identifier names and literal spelling. Preview a file before writing it, or check a directory as part of CI. The staffing walkthrough shows the input and output together.
# Print formatted source to stdout.zincite fmt model.mzn
# Check files or a directory without changing them.zincite fmt --check model.mzn data.dznzincite fmt --check models/
# Format explicit files in place.zincite fmt --write model.mzn data.dznWith 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 before-and-after examples of constraints, comprehensions, matrices and comments.
Syntax or formatting-directive errors leave the affected file untouched.
--write preserves file permissions, refuses symlinks and checks that the
source has not changed since it was read before replacing it. Other independent
files are still processed when one fails.
Format an editor buffer
Section titled “Format an editor buffer”Use the format-on-save recipe for stdin invocation, buffer replacement and failure handling. The support page links to performance measurements.
Configuration
Section titled “Configuration”The formatter reads .editorconfig files. For example:
root = true
[*.{mzn,dzn}]indent_style = spaceindent_size = 4max_line_length = 120end_of_line = lfinsert_final_newline = trueIt 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:
zincite fmt --indent-size 2 --max-line-length 80 model.mznRun zincite fmt --help (or zincite-fmt --help) for all options.
Keeping layout unchanged
Section titled “Keeping layout unchanged”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.