Skip to content

Formatting

RyeCharm can trigger Ruff to format a file on three events:

  • Reformat (Ctrl + Alt + L)
  • Optimize imports (Ctrl + Alt + O)
  • File save (Ctrl + S, editor tab close, IDE close, etc.)

Unsupported files are not affected.

Reformat#

This event happens when the Reformat Code action (Ctrl + Alt + L) is triggered, possibly with some code selected.

In Command line mode, this is equivalent to running ruff format --range ... with the file and the selected range as input.

Optimize imports#

This event happens when the Optimize Imports action (Ctrl + Alt + O) is triggered.

This is equivalent to running ruff check --fix --select I,F401 with the file as input.

File save#

This event happens when a file is saved, automatically or manually.

This is equivalent to running ruff format with the file as input.