Sergio Tapia
Sergio Tapia

Reputation: 41158

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

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 
{

}

Upvotes: 20

Views: 8488

Answers (3)

Prasoon Saurav
Prasoon Saurav

Reputation: 92864

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

Upvotes: 43

Ondra Žižka
Ondra Žižka

Reputation: 46836

Also there's the JIndent plugin.

Upvotes: 2

Vincent Ramdhanie
Vincent Ramdhanie

Reputation: 103135

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.

Upvotes: 1

Related Questions