NetBeans doesn't know how to format JS code, how can I fix it?

Of course, an IDE as powerful as NetBeans is not insignificant, but since I just print the code, here's how it formats it:

$(document).ready(function() {
    if (someVar > 2)
        {
            complain('that is not how you indent braces');
        }
        else if (someVar == -1)
            complain('this is not right either!');
        else
            {
                complain('but it did auto outdent the else which is smart');
                complain('smart indeed');
            }
});

How can I fix this, so it formats as such:

$(document).ready(function() {
    if (someVar > 2)
    {
        // this is how it done
    }
    else if (someVar == -1)
        // this is right
    else
    {
        // correct
    }
});
+5
source share
1 answer

Code formatting was not a feature available in earlier versions of NetBeans, but was added to the program with the release of NetBeans 7 (I believe). Try going to Tools → Options → Editor → Formatting and see what options you have, because that's where you can add code formatting, if you can at all.

, ( ).

+3

All Articles