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

后端 未结 4 896
深忆病人
深忆病人 2021-01-06 10:52

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 nor

相关标签:
4条回答
  • 2021-01-06 11:32
    //<editor-fold defaultstate="collapsed" desc="Your Description">
    
    .... pieces of code ....
    
    //</editor-fold>
    

    credits goes to my teacher in college

    Edited*
    
    0 讨论(0)
  • 2021-01-06 11:39

    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.

    0 讨论(0)
  • 2021-01-06 11:47

    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 讨论(0)
  • 2021-01-06 11:52

    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).
    0 讨论(0)
提交回复
热议问题