1 # HAT Code Formatting in IntelliJ
 2 [Back to Index ../](../index.md)
 3 
 4 ## How to configure it?
 5 
 6 In IntelliJ:
 7 
 8 1. Import XML for auto-formatter rules: Settings -> Editor -> Code Style ->
 9    Java -> Scheme (gear) -> Import Scheme -> IntelliJ IDEA code style XML
10 2. Select file from `hat/scripts/IDEA-xml-formatter/HAT-Formatter.xml`.
11 3. Enable Actions on Save: Settings -> Tools -> Actions on Save -> Enable
12    `Reformat Code`
13 4. Enable Optimize Imports: Settings -> Tools -> Actions on Save -> Enable
14    `Optimize Imports`.
15 
16 ## From the command line.
17 
18 You can execute Intellij's formatter from bash
19 ```bash
20  ~/Applications/IntelliJ\ IDEA\ Ultimate.app/Contents/bin/format.sh -sscripts/IDEA-xml-formatter/HAT_Formatter.xml YourJavaSource.java
21 ```