简体   繁体   English

如何在netbeans中折叠(所有类型)注释?

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

Netbeans seems inconsistent with folding comments in my Java code. Netbeans似乎与我的Java代码中的折叠注释不一致。 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 右键单击Java代码导航到

Code Folds -> Collapse All Javadoc 代码折叠 - >折叠所有Javadoc

This will fold all the comments.... 这将折叠所有评论....

在此输入图像描述

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: 要在java中折叠代码注释,您需要两个星号,如下所示:

/** / **

as opposed to just 而不是公正的

/* / *

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM