Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Surely an IDE as powerful as NetBeans isn't this clueless, but as I'm just typing out code, here is how it's formatting 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's done
    }
    else if (someVar == -1)
        // this is right
    else
    {
        // correct
    }
});
like image 864
CaptSaltyJack Avatar asked Oct 25 '22 03:10

CaptSaltyJack


1 Answers

Code formatting was not an available feature in the earlier releases of NetBeans, but was added into the program with the release of NetBeans 7 (I believe). Try going to Tools -> Options -> Editor -> Formatting and see what options you have available, because that is where you would be able to add code formatting, if you could at all.

If that doesn't solve the issue, I would recommend doing the following (in no particular order).

  • Check their docs / support page: http://netbeans.org/kb/index.html
  • Post a question on their forum.
  • Email their tech support.
  • File a support ticket on their site.
  • Ask the good folks at https://superuser.com/ (they are really good at modding software to work for them, not against them.
like image 68
Moses Avatar answered Oct 27 '22 09:10

Moses