Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>rust fmtNew to Visual Studio Code? Get it now.
rust fmt

rust fmt

vremyavnikuda

|
15 installs
| (0) | Free
Format Rust code using cargo fmt
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

rust fmt

Simple VS Code extension for formatting Rust code using rustfmt.

Requirements

You need rustfmt installed. Install it via:

rustup component add rustfmt

Verify installation:

rustfmt --version
rustc --version
rustup --version

Works on Linux, Windows, and macOS.

VS Code Settings

Add to your settings.json for automatic formatting:

"editor.formatOnSave": true,
"[rust]": {
    "editor.defaultFormatter": "rust-fmt.rust-fmt"
}

Extension Settings

  • rustfmt.path: Path to rustfmt executable (default: "rustfmt")
  • rustfmt.extraArgs: Additional arguments for rustfmt (default: [])

Usage

Automatic: Save any .rs file (if formatOnSave is enabled)

Manual:

  • Command Palette (Ctrl+Shift+P / Cmd+Shift+P) → "Format Document with rustfmt"
  • Right-click → "Format Document"
  • Shortcut: Shift+Alt+F (Windows/Linux) or Shift+Option+F (Mac)

How it works

The extension runs rustfmt --emit stdout on your code and applies the formatted result. It automatically finds and respects rustfmt.toml configuration in your project, or uses Rust standard formatting rules if no config exists.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft