Skip to main content

Formatter for QMK keymap.c LAYOUT() blocks

Project description

qmk-layout-fmt

Formatter for QMK keymap.c LAYOUT() blocks.

Aligns columns within 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qmk_layout_fmt-0.1.1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qmk_layout_fmt-0.1.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file qmk_layout_fmt-0.1.1.tar.gz.

File metadata

  • Download URL: qmk_layout_fmt-0.1.1.tar.gz
  • Upload date:
  • Size: 8.5 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

Hashes for qmk_layout_fmt-0.1.1.tar.gz
Algorithm Hash digest
SHA256 93743cebe439d6d779f4e49dbc00483332dd28fc8ebb61f9a58643398528aaf6
MD5 ec74b31bc4e2bad71ada0124ac85daa0
BLAKE2b-256 0136eee0511236550627d3e667f41466c4a4bfc0585a9ffac7059b815791037b

See more details on using hashes here.

File details

Details for the file qmk_layout_fmt-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: qmk_layout_fmt-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 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

Hashes for qmk_layout_fmt-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c381d3dcb889560a87336c2f7901be1984a044bf30c9ac614fb757bb52577ae3
MD5 9a8b1cfb9d931b00e4006dd9741a8fc7
BLAKE2b-256 c7837022f61b6171df3e6e83990cdfff6731de536f5feac36d36a00e8f94081e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page