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

青春壹個敷衍的年華 提交于 2019-11-30 18:15:38

问题


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?


回答1:


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



回答2:


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

.... pieces of code ....

//</editor-fold>

credits goes to my teacher in college

Edited*



回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/5539671/netbeans-ide-how-do-i-fold-large-chunks-of-javascript-code-in-netbeans

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!