Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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 
{

}
like image 614
Sergio Tapia Avatar asked Jan 16 '10 05:01

Sergio Tapia


People also ask

How do I enable suggestions in NetBeans?

It is easy to enable Java hints in NetBeans. Select "Tools" from the title bar, then select "Options" from the drop-down menu. Choose the "Editor" option and then select the "Hints" tab. At this point, make sure that the "Language" drop-down is set to "Java" (other choices include PHP, JavaScript, and Ruby).

How do I indent in NetBeans?

To format all the code in NetBeans, press Alt + Shift + F. If you want to indent lines, select the lines and press Alt + Shift + right arrow key, and to unindent, press Alt + Shift + left arrow key.

What is the shortcut for system out Println in NetBeans?

Type "sout" then hit tab.

What should be installed first before installing NetBeans IDE?

To use NetBeans for Java programming, you need to first install Java Development Kit (JDK). See "JDK - How to Install".


2 Answers

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
like image 164
Prasoon Saurav Avatar answered Sep 21 '22 15:09

Prasoon Saurav


Also there's the JIndent plugin.

like image 38
Ondra Žižka Avatar answered Sep 18 '22 15:09

Ondra Žižka