Folding Custom Regions with Line Comments -- 解决idea中代码收起的问题

Folding Custom Regions with Line Comments

With IntelliJ IDEA, you can surround a fragment of source code with line comments. So doing, IntelliJ IDEA supports two styles:

  • VisualStudio style
    #region DescriptionYour code goes here...#endregion
  • NetBeans style
    // <editor-fold desc="Description">Your code goes here...// </editor-fold>

Do not mix up the two styles in one file. IntelliJ IDEA will recognize the first folding comment encountered, and will assume this as a style chosen for the code.

The folding markers of a region are stored with the source code and can be shared across the team.

To surround a custom region with folding markers

  1. Select a fragment of source code.
  2. On the main menu, choose Code | Surround With, or press Ctrl+Alt+T.
  3. Select the desired folding comments from the list:customFolding1

    IntelliJ IDEA surrounds the code fragment with comments observing the syntax of the current language.

  4. If necessary, change description of the code fragment to be folded:customFolding2

    You can now collapse or expand the code.

    When collapsed, the code is concealed behind the description, and you can view it by hovering your mouse pointer over the description:

    customFolding3

Once custom regions are defined, IntelliJ IDEA provides navigation between them.

To navigate between custom regions

  1. Do one of the following:
    • On the main menu, choose Navigate | Custom Region.
    • Press Ctrl+Alt+Period.
  2. In the dialog box that opens, select the target custom region, and click OK:navigateToCustomRegion

    The caret rests at the comment line opening the region in question.

转载于:https://my.oschina.net/u/2436679/blog/645557

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值