Joe232
July 4, 2019, 12:38am
1
I am using Visual Studio Code and using the Rust's default formatter, and if I were to press shift
+alt
+F
it will look like this.
fn main() {
println!("Hello World");
}
How do I override the settings to look like this.
fn main()
{
println!("Hello World");
}
leudz
July 4, 2019, 12:51am
2
You can add a rustfmt.toml
to your project's directory or a few others places and specify the brace_style .
1 Like
I am in htis directory C:\Users\%username%\AppData\Roaming
. Do you know where do I go to modify the global file that controls the Rustfmt
?
leudz
July 4, 2019, 4:46am
4
You just have to create a new directory there called rustfmt
with a rustfmt.toml
inside.
Ok so I did that, do I put this inside the new cargo.toml file?
brace_style: "AlwaysNextLine";
I am kinda new to all of this so I don't have much of an understanding.
leudz
July 4, 2019, 6:14am
6
No, you put it in the rustfmt.toml
you creates in C:\Users\%username%\AppData\Roaming\rustfmt
, and no need for the ;
at the end.
Also I just saw you need to use the nightly version of rustfmt
to use this specific option.
You can do it by choosing the nightly toolchain as default or call cargo
with +nightly
. (cargo +nightly fmt
)
system
Closed
October 2, 2019, 6:21am
7
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.