Is there a way for NetBeans to automatically create brackets in a separate line?

纵饮孤独 提交于 2019-12-03 20:37:06

问题


When I create a new class for instance, I get this:

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

package helloworld;

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

I hate it when brackets are placed this way. Is there a way to make it create things like this:

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

package helloworld;

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

}

回答1:


Simply follow these steps:

  1. Navigate to Tools -> Options -> Editor
  2. Navigate to Editor -> Formatting
  3. Select the following
    • Language: Java
    • Category: Braces
  4. In "Class Declaration, Method Declaration, etc."
    • Braces Placement: New Line



回答2:


Also there's the JIndent plugin.




回答3:


In Netbeans go to Tools > Options. Then select the Formatting tab and select Java under the language drop down.

There are now several options to change the formatting the way you like it.



来源:https://stackoverflow.com/questions/2076262/is-there-a-way-for-netbeans-to-automatically-create-brackets-in-a-separate-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!