For IntelliJ IDEA, create a new File Watcher to format code when a file changes.
- Open Preferences
- Go to "Tools > File Watchers"
- Create a new file watcher and set the following:
- “Name”: “format everything”
- “File type”: “Any”
- “Scope”: “All Places”
- “Program”: “$ProjectFileDir$/bin/dev/format”
- “Arguments”: “$FilePath$”
- “Output paths to refresh: “$FilePath$”
- “Working directory”: “$ProjectFileDir$”
- Expand "Advanced Options"
- Uncheck "Auto-save edited files to trigger the watcher"
- Uncheck "Trigger the watcher on external changes"