Read source code from stdin, output formatted file to stdout.
Usage:
v fmt [options] path_to_source.v [path_to_other_source.v]
v fmt [options] path/to/dir [path/to/other_dir]
cat source.v | v fmt
Formats the given V source files or recursively formats all files in the
directory, then prints their formatted source to stdout.
Options:
-c Check if a file is already formatted. If not, print the
filepath and exit with code 2. Compared to -verify it is
quicker but has a small trade-off in precision.
-diff Display the differences between the formatted source(s)
and the original source(s). This will attempt to find a
working `diff` command automatically unless you specify one
with the VDIFF_CMD environment variable.
-l List files whose formatting differs from vfmt.
-w Write result to (source) file(s) instead of to stdout.
-backup In combination with `-w`, copy the original `file.v` to a
`file.v.bak` backup, before overwriting the original source
file.
-debug Print the kinds of encountered AST statements/expressions
on stderr.
-verify Make sure the provided file is already formatted. Useful for
checking code contributions in CI for example.
-inprocess Do everything in the same process. More prone to crashes in
case of parser bugs for invalid source files, and it needs
more memory, but it is faster for thousands of files, since
it avoids the interprocess communication overhead.
-new_int Forcefully cast the `int` type in @[translated] modules or
in the definition of `C.func` to the `i32` type.
Environment Variables:
VDIFF_CMD A custom tool and options that will be used for viewing the
differences between the original and the temporarily formatted
files, e.g.: `VDIFF_CMD="diff -y -W 100" v fmt -diff path/file.v`