HiveBrain v1.2.0
Get Started
← Back to all entries
snippetrustCritical

How to run cargo fmt on save in vscode?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
runsavehowfmtcargovscode

Problem

Is it possible to make Visual Studio Code run cargo fmt on file save?

Solution

Install the extension rust-analyzer (the officially recommended vscode extension), and add the following to settings.json:

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

Code Snippets

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

Context

Stack Overflow Q#67859926, score: 115

Revisions (0)

No revisions yet.