【问题标题】:Is there a way for NetBeans to automatically create brackets in a separate line?NetBeans 有没有办法在单独的行中自动创建括号?
【发布时间】:2010-01-16 05:07:37
【问题描述】:

例如,当我创建一个新类时,我得到了这个:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package helloworld;

/**
 *
 * @author Sergio
 */
public class WordManipulations{        
}

当括号以这种方式放置时,我讨厌它。有没有办法让它创造这样的东西:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package helloworld;

/**
 *
 * @author Sergio
 */
public class WordManipulations 
{

}

【问题讨论】:

  • 你在说什么? :S
  • hehe 有趣的是,我有 Java 中使用的那种风格(大括号在新行中)。就像我讨厌 C# 使用前者(在同一行中的左大括号)一样,我认为每种语言都应该遵守核心使用的约定。

标签: java ide netbeans brackets


【解决方案1】:

只需按照以下步骤操作:

  1. 导航到Tools -> Options -> Editor
  2. 导航到Editor -> Formatting
  3. 选择以下
    • 语言:Java
    • 类别:大括号
  4. 在“类声明、方法声明等”中
    • 大括号放置:新行

【讨论】:

  • 哇,太简单了。 Netbeans 确实令人印象深刻。
  • 不幸的是,目前在 Netbeans 6.8 中这已被破坏(至少对于 C/C++ 和 PHP):(
【解决方案2】:

还有 JIndent 插件。

【讨论】:

    【解决方案3】:

    在 Netbeans 中转到 工具 > 选项。然后选择Formatting选项卡并在语言下拉菜单下选择Java

    现在有几个选项可以按照您喜欢的方式更改格式。

    【讨论】:

      猜你喜欢
      • 2019-01-08
      • 2014-07-13
      • 2015-10-29
      • 1970-01-01
      • 1970-01-01
      • 2010-12-04
      • 2020-05-19
      • 2022-10-12
      • 1970-01-01
      相关资源
      最近更新 更多