【问题标题】:Align lines with opening and closing brackets将行与左括号和右括号对齐
【发布时间】:2016-08-26 02:09:51
【问题描述】:

问题

我希望 linesclosure 大括号/括号/括号具有完全相同的 indent 作为 lines 带有匹配的开口大括号/方括号/括号。

经过一番搜索,我猜我的需求很特别,但也许我只是错过了一些东西。是否可以将 Eclipse 自动格式化程序配置为以这种方式运行? (我花了好几个小时来切换复选框,但到目前为止还不能让它如此运作。)

示例

换句话说,我会用 Eclipse 来格式化:

public String concatenate(String a,
        String b) {
    ...
}

这样:

public String concatenate(
    String a, String b
) {
    ...
}

// The same, but with some extra comments:

public String concatenate( // the line with "(" has no indent
    String a, String b
) { // so, the line with the matching ")" also should not
    ...
} // same goes for {} and []

【问题讨论】:

  • 为什么?没有语言使用该格式作为标准?
  • 尽管我无法想象曾经使用过这种确切的样式,但我认为这是一个值得提出的问题,因为我们可能会了解您可以在多大程度上自定义 Eclipse 格式,以及您将如何做到这一点。
  • 为什么你必须掺杂像eclipse这样的IDE采用的java的漂亮代码格式约定?

标签: java eclipse code-formatting eclipse-formatter


【解决方案1】:

看起来您应该能够在 Eclipse Neon Milestone 7 版本 (4.6M7) 中执行此操作,该版本增加了代码格式化程序(请参阅 What's New and Noteworthy 中的“代码格式化程序的新选项”部分以了解该版本)。

注意:Milestone 版本是 Eclipse 版本的早期版本,可能不如最终版本稳定(Eclipse Neon 将于 2016 年 6 月发布)。

【讨论】:

  • 确实! This 看起来正是我想要的样子!谢谢:)
猜你喜欢
  • 2019-02-03
  • 2016-11-16
  • 1970-01-01
  • 2012-02-25
  • 2020-01-30
  • 2017-07-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多