A fast, configurable Fortran formatter with support for Fypp, Doxygen, and OpenACC/OpenMP directives. Written in Rust. Installable via pip.
Documentation | Configuration | Changelog
pip install ffmtOr via Cargo:
cargo install ffmtffmt src/ # format in-place
ffmt --check src/ # CI mode (exit 1 if changes needed)
ffmt --diff src/ # show colored diff
ffmt -j 8 src/ # parallel
cat file.fpp | ffmt - # stdin/stdout- Code -- indentation, whitespace normalization, keyword casing, named ends, line wrapping, operator modernization (
.eq.->==), double-colon enforcement, trailing semicolon removal - Comments -- rewrapping, inline spacing (S102),
!<alignment,!&/& !cleanup, format suppression (! ffmt off/on) - Structure -- blank line management around openers/closers/
#ifdef, declaration::alignment, declaration/use compaction - Preprocessor -- Fypp (
#:if,$:,@:), C preprocessor (#ifdef), OpenACC (!$acc), OpenMP (!$omp) - Opt-in -- multi-statement splitting, assignment alignment,
&column alignment, use-statement reformatting
Most options accept true, false, or "preserve". See the configuration reference for all options.
Create ffmt.toml or add [tool.ffmt] to pyproject.toml:
indent-width = 4
line-length = 132
keyword-case = "lower"
modernize-operators = true
enforce-double-colon = true
[whitespace]
relational = true
multdiv = false# GitHub Actions
- uses: sbryngelson/ffmt@latest
with:
args: "--check src/"# pre-commit
repos:
- repo: https://github.com/sbryngelson/ffmt
rev: v0.3.5
hooks:
- id: ffmt| Formatter | Language | Status | Notes |
|---|---|---|---|
| fprettify | Python | Unmaintained | Free-form only. Fypp support. |
| findent | C | Active | Indentation and fixed/free conversion. |
| Codee Formatter | Proprietary | Active | Commercial. Tree-sitter based. |
| LFortran fmt | Rust | In development | AST-based. |
| Fortitude | Rust | Active | Linter with auto-fix. |
MIT