QMK Format
qmkfmt is a tool to format the keymaps section of a keymap.c file in qmk.
It formats each LAYOUT entry under keymaps into a grid with aligned columns.
Bug reports, feature requests, and contributions are welcome!
Installation
Pre-compiled binaries are available on the releases page.
To install the latest release from crates.io:
To install the latest from git:
Behavior
qmkfmt is designed to work out of the box with no configuration.
qmkfmt infers the number of rows from the number of lines in each LAYOUT.
If a row has less than the maximum number of columns (e.g. a thumb cluster), it is centered.
For example, the following keymap:
=
Will be reformatted to:
=
If clang-format is available on $PATH, qmkfmt will invoke it to format the rest of the file.
Configuration
The --split-spaces flag controls the given number of spaces in the center of each layout.
Pass --split-spaces=0 if the keyboard is not split and you want no separation between halves.
Usage
CLI
Simply run qmkfmt path/to/keymap.c to format the file inline.
If not given a path, qmkfmt reads stdin and writes to stdout.
Helix
Put the following in .helix/languages.toml at the root of the qmk_firmware repository:
[[]]
= "c"
= true
= { = "qmkfmt", = ["--split-spaces=8"] }