【问题标题】:PhpStorm define collapsible code regions (Visual Studio style Regions) possible?PhpStorm 定义可折叠的代码区域(Visual Studio 风格的区域)可能吗?
【发布时间】:2011-10-27 22:50:53
【问题描述】:

在 Visual Studio 中,您可以使用 #region#endregion 包装开发人员定义的代码块。

我很想在 PhpStorm 中看到这个功能,它是组织大型源文件(例如大量接口实现)的理想方式。

是否可以让 PhpStorm 以这种方式运行?

【问题讨论】:

    标签: folding phpstorm


    【解决方案1】:

    抱歉,目前不可以。

    请投票并观看这张票:https://youtrack.jetbrains.com/issue/WI-261


    更新
    它现在已经实现(自 PhpStorm v4)——查看 PhpStorm 的博客了解详细信息:http://blog.jetbrains.com/webide/2012/03/new-in-4-0-custom-code-folding-regions/


    //<editor-fold desc="Region">
    
    // Your code goes here
    
    //</editor-fold>
    

    现在也正确支持默认折叠状态(从 PhpStorm v8、IIRC 开始),尽管您必须自己手动添加这样的部分。例如

    //<editor-fold defaultstate="collapsed" desc="Region">
    

    还支持#region syntax

    【讨论】:

    • 它现在可以工作了,顺便说一句。至少在 EAP 构建中。只需将您的代码放在#region#endregion 中即可。
    • @Nate 查看正确链接的更新答案:blog.jetbrains.com/webide/2012/03/…
    • @LazyOne 啊谢谢 - 还要注意 #rangeregion 也适用于折叠
    【解决方案2】:

    我也在寻找这个,发现它现在可以在版本 4 EAP 中使用。

    工作示例:

    // region Private members
    private $db;
    private $cache;
    // endregion
    

    【讨论】:

    • 这是超越使用标签的好方法!更像是 VS,我认为它们做得很好。
    • 这是最简单的方法!
    猜你喜欢
    • 1970-01-01
    • 2017-08-08
    • 1970-01-01
    • 2014-06-02
    • 2019-04-13
    • 2014-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多