开发者

Netbeans IDE : How do I fold large chunks of Javascript code in Netbeans?

I have taken the leap from my comfortable dreamweaver IDE to Netbeans and am missing my code folding options :(

I see with Netbeans you can fold normal functions but I can't seem to work out how to fold large chunks (entire modules). I have found fixes for other languages in Netbeans but they don't seem to work in Javascript. This is very frustrating when working on my large 4000+ line files...

Surely there is a way?! If not can anyone recommend an IDE that is good for JS, CSS, HTML and PHP开发者_StackOverflow社区?


//<editor-fold defaultstate="collapsed" desc="Your Description">

.... pieces of code ....

//</editor-fold>

credits goes to my teacher in college

Edited*


The shortcut key for folding all of the data in any file type is "Ctrl + Shift + - (minus sign)".
To expand fully that file, you need to do the opposite, which is "Ctrl + Shift + + (plus sign)".

To see & edit the whole Keyboard Shortcuts of NetBeans IDE, please go to the "Tools Menu > Options > Keymap Tab".

Hope it helps.

Update for Folding Code Structures other than the Functions itself:-
Follow these steps:-

  • Go to this section "Tools Menu > Options > Editor Tab > General Sub-Tab".
  • You will find 2 sections in there - "Code Folding" & "Camel Case Behavior".
  • In the section of "Code Folding", there are two sub-sections - "Use Code Folding" & "Collapse by Default".
  • Check the checkbox for the sub-section "Use Code Folding", to activate the other options of the other sub-section.
  • In the other sub-section "Collapse by Default", you will find 6 options. Among them, your required option is the "Tags and Other Code Blocks". Check the checkbox of this option, to activate code folding for all code structures (like "if" & "for" logic, ...), and then restart the application (otherwise it MAY NOT work).


NetBeans 7.3 Beta 2 has improved code-folding for javascript. You can add custom fold comments to block off whatever you want:

// <editor-fold>
... code ...
// </editor-fold>

More information here.

After a week of use the beta version of NetBeans mysteriously slowed down. I reinstalled it, which is a bit of a chore, but no problems since then. The code folding is very helpful.


The short answer is that there is no way to fold code by matched parens with out using their hideous NB specific XML tags (which means anyone else looking at your code in any other IDE is going to get extremely confused).

This needs to be fixed but Oracle doesn't seem to care.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜