【问题标题】:Can I set IntelliJ to auto indent the code body?我可以将 IntelliJ 设置为自动缩进代码体吗?
【发布时间】:2013-04-18 06:34:14
【问题描述】:

问题一: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
        }

这是我在“设置”选项中似乎找不到的另一件事。

任何帮助都会很棒。感谢您的宝贵时间。

【问题讨论】:

    标签: java intellij-idea ide indentation


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      IntelliJ IDEA 15

      文件>设置...>编辑器>代码样式>Java>包装和大括号>大括号放置>在方法声明中>下一行,每个移动

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-10-18
        • 2013-10-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多