Formatter for QMK (https://qmk.fm/) keymap.c LAYOUT() blocks
Project description
qmk-layout-fmt
Formatter for QMK keymap.c LAYOUT() blocks.
QMK is an open-source firmware for custom keyboards. Keymaps are defined in C files using LAYOUT() macros that map physical keys to actions across multiple layers.
This tool aligns columns within those layer definitions so that keys line up vertically across rows, making keymaps easier to read and review.
Works with any QMK LAYOUT macro — auto-detects shape from standard names (LAYOUT_split_3x6_3, LAYOUT_ortho_4x12, etc.) and supports custom macros via config file.
Installation
With uv:
uv tool install qmk-layout-fmt
With pipx:
pipx install qmk-layout-fmt
Or directly from the repository:
uv tool install git+https://github.com/OneDeadKey/qmk-layout-fmt
Development
git clone https://github.com/OneDeadKey/qmk-layout-fmt.git
cd qmk-layout-fmt
uv sync
uv run qmk-layout-fmt keymap.c
Maintainer tasks
Requires just:
just build # build the package
just publish # build + publish to PyPI
just bump 0.2.0 # update version everywhere
just run keymap.c # run the formatter locally
Usage
# Format in place (default)
qmk-layout-fmt keymap.c
# Check formatting without modifying (exit code 1 if unformatted, useful for CI)
qmk-layout-fmt keymap.c --check
# All layers share the same column widths (default: each layer aligns independently)
qmk-layout-fmt keymap.c --uniform
Layout shape override
For standard QMK macros (LAYOUT_split_3x6_3, LAYOUT_ortho_4x12, LAYOUT_planck_grid, etc.), the shape is auto-detected from the macro name.
For custom macros, use CLI flags:
qmk-layout-fmt keymap.c --main-rows 4 --cols-per-side 6 --thumb-per-side 3
Or create a .qmk-layout-fmt.toml config file in your project (searched upward from the input file):
[layouts.MY_CUSTOM_LAYOUT]
main_rows = 4
cols_per_side = 6
thumb_per_side = 3
Supported layouts
| Macro pattern | Auto-detected | Example |
|---|---|---|
LAYOUT_split_{R}x{C}_{T} |
rows, cols per side, thumbs per side | LAYOUT_split_3x6_3 → 3 rows of 6+6, thumb 3+3 |
LAYOUT_ortho_{R}x{C} |
rows, cols split in half | LAYOUT_ortho_4x12 → 4 rows of 6+6 |
LAYOUT_planck_grid |
4 rows of 6+6 | |
| Custom macros | via .qmk-layout-fmt.toml or CLI flags |
ONEDEADKEY_LAYOUT |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qmk_layout_fmt-0.1.2.tar.gz.
File metadata
- Download URL: qmk_layout_fmt-0.1.2.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4660fe5dad59de343bc6cedd45dd767531f43aef7e2ffd48f286b9e04403b29f
|
|
| MD5 |
86240409e0577c1e766bcacd2cc181fa
|
|
| BLAKE2b-256 |
6ad0aacdbb90e33b1fd3ffb12bb274881f0c9cbcabcd5040b9af9f374dc0af6e
|
File details
Details for the file qmk_layout_fmt-0.1.2-py3-none-any.whl.
File metadata
- Download URL: qmk_layout_fmt-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e08f6de248f8027e64b91c888117fa643ff1af51cc22d0283c747e7ce4186113
|
|
| MD5 |
8cbebab1f859e2c0391d334eb446fced
|
|
| BLAKE2b-256 |
02e957e8058a61b76296832d249ca63231786799f5065ffc3d6f08c3f281dbc9
|