我可以将IntelliJ设置为自动缩进代码体吗?

时间:2013-04-18 06:34:14

标签: java intellij-idea ide indentation

问题1:IntelliJ可以设置为在创建新行时自动缩进代码体吗?

这是我的意思的一个例子:

我有这个方法:

    public static void main(String[] args)
        {
            System.out.println("Hi there.");
        }

在输入表达式后按下返回键,我得到了这个:

    public static void main(String[] args)
        {
            System.out.println("Hi there.");
        // the new line aligns itself with the braces.
        }

我希望这样做:

    public static void main(String[] args)
        {
            System.out.println("Hi there.");
            // the new line aligns itself with the preceding line
        }

我无法在“设置”下的任何位置找到可以使其成为默认行为的选项。它存在吗?我错过了它还是我在寻找一只独角兽?

问题2:是否有选项可以默认缩进代码体?如果是这样,它在哪里可以找到?

示例:

使用“重新格式化代码...”命令后,我得到了这个:

    public static void main(String[] args)
        {
        System.out.println("Hi there.");
        // the code body is realigned with the braces
        }

是否可以设置IntelliJ来执行此操作,如果可以,我在哪里可以找到该选项?:

    public static void main(String[] args)
        {
            System.out.println("Hi there.");
            // the code body is indented from the braces
        }

这是我在“设置”选项中无法找到的另一件事。

任何帮助都会很棒。谢谢你的时间。

2 个答案:

答案 0 :(得分:4)

您应该使用Next line, each shifted选项:

enter image description here

答案 1 :(得分:0)

IntelliJ IDEA 15

档案>设置...>编辑>代码风格> Java>包裹和支撑>大括号放置>在方法声明中> 下一行,每次都移动

Next line each shifted