Format Source

I guess I should have realised that starting a new blog on the 13th (even though it was not a Friday), might be a bad idea. πŸ™‚ Soon after the first post I experienced technical difficulties with the server. Today I finally got around to setting everything up again, so here is the first real post. πŸ™‚

One of my favourite features of the NetBeans IDE is source formatting. With the press of a few buttons (Alt + Shift + F) (or Source | Format from the menu bar), you can convert a real mess…

package javaapplication1;public class JavaApplication1 {/*** @param args the command line arguments*/public static void main(String[] args) {System.out.println("Hallo World!");}}

into something a lot more readable…

package javaapplication1;

public class JavaApplication1 {

     * @param args the command line arguments
    public static void main(String[] args) {
        System.out.println("Hallo World!");

The format is highly configurable, to suit the preferences of all developers. The settings can be accessed from Tools | Options, in the Editor category on the formatting tab.

Source formatting is not limited to Java source code though – it works equally well for XML. For example, from

<?xml version="1.0" encoding="UTF-8"?><root><tag1><tag2><tag3></tag3></tag2></tag1></root>


<?xml version="1.0" encoding="UTF-8"?>

Leave a Comment