Can I set IntelliJ to auto indent the code body?
ide, indentation, intellij-idea, java
Solution
You should use the `Next line, each shifted` option:
Problem
Question 1: Can IntelliJ be set to indent the code body automatically upon making a new line? Here is an example of what I mean: I have this method: ``` public static void main(String[] args) { System.out.println("Hi there."); } ``` Upon hitting the return key after typing the expression, I get this: ``` public static void main(String[] args) { System.out.println("Hi there."); // the new line aligns itself with the braces. } ``` I would like it to do this: ``` public static void main(String[] args) { System.out.println("Hi there."); // the new line aligns itself with the preceding line } ``` I haven't been able to locate an option anywhere under Settings that would make this the default behavior. Does it exist and am I missing it or am I looking for a unicorn? Question 2: Is there an option to have the code body indented by default? If so, where can it be found? Example: Upon using the "Reformat Code..." command, I get this: ``` public static void main(String[] args) { System.out.println("Hi there."); // the code body is realigned with the braces } ``` Is it possible to set IntelliJ to do this, and if so, where can I find that option?: ``` public static void main(String[] args) { System.out.println("Hi there."); // the code body is indented from the braces } ``` That is another thing I cannot seem to find in the Settings options. Any help would be great. Thanks for your time.