开发者

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 t开发者_运维技巧his 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
    }
});


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜