sincecutoff.com
← all changes

jj fix can format selected line ranges

Introduced 2026-05-07 · score 0.98

HOW TO USE IT

When a configured formatter supports line ranges, set `fix.tools.<name>.line-range-arg` to pass each modified range and optionally set `run-tool-if-zero-line-ranges` to run it when no ranges are available. Run `jj fix --all-lines` to format whole modified files.

[fix.tools.<name>] command = ["<formatter>", "<formatter-args>"] patterns = ["<fileset>"] line-range-arg = "--lines=$first:$last" run-tool-if-zero-line-ranges = false jj fix --all-lines

WHY THIS HELPS

Format only modified lines when running `jj fix` on files with configured formatting tools.

BEFORE THIS CHANGE

Without line-range configuration, the tool processes the entire file; `--all-lines` formats the entire modified file when line ranges are configured.

REQUIREMENTS AND LIMITATIONS

  • Version: v0.41.0
  • fix.tools.<name>.command (required): Arguments to run the tool; first argument is its executable path.
  • fix.tools.<name>.patterns (required): Filesets selecting affected files; an empty list matches no files.
  • fix.tools.<name>.line-range-arg: Template string passed for each modified range; `$first` and `$last` are 1-based endpoints. Deletion-only empty ranges are skipped.
  • fix.tools.<name>.run-tool-if-zero-line-ranges: Run the tool when no line ranges were calculated; defaults to `false`. Not mutually exclusive with `line-range-arg`.
  • --all-lines: Format all lines instead of only modified lines; short form `-a`.
  • Prerequisite: Configure a fix tool with a command and matching fileset patterns. For line-limited formatting, the formatter must support the configured range argument.
  • `--all-lines` matches the previous behavior of formatting the entire file when `line-range-arg` is set.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card