nelson-format
Command-line Nelson source formatter.
📝Syntax
nelson-format [--include-subfolders true|false] [--indent-size n] [--full-format true|false] [--config file] [--check] path ...
📄Description

nelson-format formats Nelson source files from the command line.

Files are formatted in place by default. The formatter only processes files with the .m extension.

--include-subfolders enables recursive formatting when a folder is passed as input.

--indent-size sets the indentation size. The default value is 2.

--full-format enables or disables full formatting. The default value is true. Set it to false to only update leading indentation.

Full formatting preserves package, member, and dynamic-field references such as package.function(value.(name)). Contextual class block names remain ordinary identifiers when used in executable statements.

--config loads a JSON configuration file. Without this option, nelson-format looks for nelson-format.json from the input paths and then from the current folder.

--check reports files that would change without writing them.

Single-line blocks retain their opening and closing statements. Their indentation does not affect subsequent lines, and indexing expressions using end remain distinct from block terminators.

Inline catch clauses preserve the separator after an optional exception variable, including forms such as catch err, value = err.message;.

The supported configuration keys are indentSize, fullFormat, includeSubfolders, and excludePathContains. Command-line options override values loaded from JSON.

Files listed by nelson-format-ignore.json or by excludePathContains in nelson-format.json are skipped.

Exit code 0 means success or no change required, 1 means --check found files that would change, and 2 means usage, input, read/write, or internal error.

💡Examples
Format all Nelson files in a folder recursively.
nelson-format --include-subfolders true modules/interpreter/functions
Check whether a file is already formatted.
nelson-format --check myfile.m
Format with an explicit configuration file.
nelson-format --config nelson-format.json modules/interpreter/functions
Used Functions
smartindent
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub