Search code examples
javascriptnetbeansfolding

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?


Solution

  • 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).