开发者

How to fold (all types of) comments in netbeans?

开发者 https://www.devze.com 2023-02-22 16:08 出处:网络
Netbeans seems inconsistent with folding comments in my Java code. Sometimes I can fold the comments, and sometimes I cannot. Any help? Thank you开发者_如何学编程.You can also include something like

Netbeans seems inconsistent with folding comments in my Java code. Sometimes I can fold the comments, and sometimes I cannot. Any help? Thank you开发者_如何学编程.


You can also include something like

// <editor-fold defaultstate="collapsed" desc="stuff to be collapsed">
/* start of comment
...
*/
// </editor-fold>


Right click on you Java code navigate to

Code Folds -> Collapse All Javadoc

This will fold all the comments....

How to fold (all types of) comments in netbeans?


I have functions with very long lines, I usually do this

// <editor-fold defaultstate="collapsed" desc="Description (Example Execute)">
 /**
 *
 * Execute the query
 *
 * Accepts an SQL string as input and returns a result object upon
 * successful execution of a "read" type query. Returns boolean TRUE
 * upon successful execution of a "write" type query. Returns boolean
 * FALSE upon failure, and if the $db_debug variable is set to TRUE
 * will raise an error.
 *
 * @param   string  $sql
 * @param   array   $binds = FALSE      An array of binding data
 * @param   bool    $return_object = NULL
 * @return  mixed
 */

 public function query($sql, $binds = FALSE, $return_object = NULL){
 /* exmample code here */
 }

 // </editor-fold>

I hope that will be useful :))


Also Check:

Tools --> Options -- > Editor

There are a heap of check boxes there to configure default folding.


I figured out why:

To fold code comments in java, you need two asterisks, like this:

/**

as opposed to just

/*

0

精彩评论

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

关注公众号