Multi-language formatting plugin for the Micro editor
git cloneandmake- Install whichever formatters you want to use
Commands in this section are micro commands. Use
Ctrl-eto open the command bar inside micro. You can usesetlocalin place ofsetto change a setting only in the current buffer.
Run fmt to format the current file with the default/chosen formatter, or fmt <name> to run a specific formatter (e.g. fmt ruff+check).
By default, files will be formatted on save. Disable with set autofmt.onsave false.
Formatters are named command invocations. For languages with multiple formatters, choose one with set autofmt.for-<language> <name> (e.g. set autofmt.for-python ruff). Some languages have multiple formatters that run the same command with different settings, see the exact invocations below.
The first formatter listed for each language is the default.
| Language | Formatter name(s) |
|---|---|
| C/C++/C# | clang-format |
| CSS | prettier |
| Go | gofmt |
| HTML | prettier |
| JavaScript | prettier |
| JSON | prettier |
| Lua | stylua |
| Nix | nixfmt |
| Python | yapf, ruff, ruff+check, black |
| Racket | raco-fmt |
| Rust | rustfmt, rustfmt+nightly |
| Solidity | forge-fmt |
| TypeScript | prettier |
| Name | Invocation |
|---|---|
| black | black -q |
| clang-format | clang-format -i |
| forge-fmt | forge fmt |
| gofmt | gofmt -w |
| nixfmt | nixfmt |
| prettier | prettier --write --log-level silent |
| raco-fmt | raco fmt --width 80 --max-blank-lines 2 -i |
| ruff | ruff format -s |
| ruff+check | ruff check --fix and ruff format -s |
| rustfmt | rustfmt |
| rustfmt+nightly | rustfmt +nightly |
| stylua | stylua |
| yapf | yapf -i |
This project is intended as a replacement for the now-dead fmt-micro. o7
All contributions are welcome by pull request or issue.
micro-autofmt is licensed under the GNU General Public License v3.0. See LICENSE for full text.