java 代码 折叠_如何折叠一段代码使整个代码看起来简洁

Java netBeans/Eclips 如何折叠一段代码使整个代码看起来简洁

最近刚用Java,以前写C#的时候,通过region操作可以使一段代码折叠起来,使整段程序缩成一行,看起来清爽了许多,现在用netBeans, 发现自带的代码折叠功能只能折叠一个整个的method,不能选择一段进行折叠,请问能实现类似于C#的功能吗?

如 #region

很长的代码

#endregion

NetBeans内Editor设置了类似的功能。

只需要在模块开始注释以//开始,

在模块结束行以 //结束即可

本人测试有效

Can I Create Custom Code Folds?

Apart from usual folds, you can define custom folds. To add your custom fold, type in two special comments as shown in this example:

//

Your code goes here...

//

You may define the default description of a collapsed fold by adding a "desc" tag:

//

Your code goes here...

//

You may set a fold to be collapsed by default by adding a "defaultstate" tag:

//

Your code goes here...

//

Please note that the above examples are for java language. In other languages custom folds may not be supported or you may have to use different characters for marking line comments. Also  element syntax is not a real XML, we use a simple regex to find your custom folds in a document, which means that there are limitations in the syntax. The most important one is that attributes may only be combined in this specific order: defaultstate, desc.

Applies to: NetBeans 5.x, 6.x

Platforms: All

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值