Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>µfmtNew to Visual Studio Code? Get it now.
µfmt

µfmt

Omnilib Project

omnilib.dev
|
11,498 installs
| (2) | Free
Safe, atomic formatting with black and µsort
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

µfmt: safe, atomic formatting and import sorting

µfmt is a code formatter and import sorter for Python and Visual Studio Code, built on top of black and µsort, with experimental support for ruff-api:

Black makes code review faster by producing the smallest diffs possible. Blackened code looks the same regardless of the project you’re reading.

μsort is a safe, minimal import sorter. Its primary goal is to make no “dangerous” changes to code, and to make no changes on code style.

µfmt formats files in-memory, first with µsort and then with black, before writing any changes back to disk. This enables a combined, atomic formatting steps in VS Code, without any chance of conflict or intermediate changes between the import sorter and the code formatter.

Note:

  • This extension requires Python version 3.9 or newer.
  • The extension comes bundled with the latest version of µfmt 2.x, as well as black, µsort, and ruff-api.

Usage

Once installed, "µfmt" will be available as a formatter for Python files (extension id: omnilib.ufmt). µfmt can be set as the default formatter by adding the following to your settings:

"[python]": {
    "editor.defaultFormatter": "omnilib.ufmt"
}

or through the command pallete option "Format Document With...":

Command pallete 'format document with' Follow-up option 'Configure default formatter'

Be sure to disable the legacy Python formatter, if enabled:

"python.formatting.provider": "none"

Format on Save

VS Code can automatically format your Python files when saving by adding the following to your settings:

"[python]": {
    "editor.defaultFormatter": "omnilib.ufmt",
    "editor.formatOnSave": true
}

Resources

  • µfmt documentation
  • black documentation
  • µsort documentation
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft