VS Code extension for formatting Rust code with rustfmt.
Supports:
- File formatting (including format on save)
- Workspace formatting (
cargo fmt-optimized) - Git-aware formatting (
changed/stagedRust files) - Status bar + Control Center quick actions
- Native
macro_rules!body formatting (opt-in)
rustup component add rustfmtWorks on Linux, Windows, macOS.
| Setting | Default | Description |
|---|---|---|
rustfmt.path |
"rustfmt" |
Path to rustfmt executable |
rustfmt.extraArgs |
[] |
Additional rustfmt arguments |
rustfmt.onboarding.mode |
"quiet" |
Onboarding mode (quiet / guided) |
nativeMacroFormatter.native |
false |
Enable macro_rules! body formatting |
nativeMacroFormatter.path |
auto | Path to rust-fmt-mf binary |
Set as default formatter in settings.json:
"[rust]": {
"editor.defaultFormatter": "vremyavnikuda.rust-fmt",
"editor.formatOnSave": true
}| Command | Description |
|---|---|
| Format Document with rustfmt | Current file (on save) |
| Format Workspace with rustfmt | All Rust files in workspace |
| Format Changed Rust Files | Files from git diff |
| Format Staged Rust Files | Files from git diff --cached |
| Open Control Center | Quick action menu |
| Open Logs | Output channel |
Runs rustfmt --emit stdout with auto-detected crate root, edition, and config. When nativeMacroFormatter.native is enabled, formats macro_rules! bodies via rust-fmt-mf (skipped by standard rustfmt).
Also detects rust-toolchain and rustfmt.toml, skips files over 2 MB.
rustfmtnot found: runrustup component add rustfmtor setrustfmt.path.
