2018-10-23 09:07:46 +02:00
# Running Rustfmt from IntelliJ or CLion
## Installation
- Install [CLion ](https://www.jetbrains.com/clion/ ), [IntelliJ Ultimate or CE ](https://www.jetbrains.com/idea/ ) through the direct download link or using the [JetBrains Toolbox ](https://www.jetbrains.com/toolbox/ ).
2020-06-06 17:19:50 +03:00
CLion and IntelliJ Ultimate [provide a built-in debugger interface ](https://github.com/intellij-rust/intellij-rust#compatible-ides ) but they are not free like IntelliJ CE.
- Install the [Rust Plugin ](https://intellij-rust.github.io/ ) by navigating to File → Settings → Plugins and searching the plugin in the Marketplace

2018-10-23 09:07:46 +02:00
2020-06-06 17:19:50 +03:00
- Press "Install" on the Rust plugin

2018-10-23 09:07:46 +02:00
- Restart CLion/IntelliJ
## Configuration
2020-06-06 17:19:50 +03:00
### Run Rustfmt on save
- Open Rustfmt settings (File → Settings → Languages & Frameworks → Rust → Rustfmt) and enable "Run rustfmt on Save"

2024-01-25 18:55:23 -05:00
- IntelliJ uses autosave, so now your files will always be formatted according to rustfmt. Alternatively you can use Ctrl+S to reformat file manually
2020-06-06 17:19:50 +03:00
### Bind shortcut to "Reformat File with Rustfmt" action
- Open the settings window (File → Settings) and search for "reformat"
2018-10-23 09:07:46 +02:00

- Right-click on "Reformat File with Rustfmt" and assign a keyboard shortcut

- Press "OK"

- Done. You can now use rustfmt in an opened *.rs file with your previously specified shortcut