PHP #region for code folding?

前端 未结 15 1425
星月不相逢
星月不相逢 2021-01-31 14:06

Is there an equivilent of c#\'s #region in PHP?

相关标签:
15条回答
  • 2021-01-31 15:01

    Although this is an old thread, but if one is still interested one can set a shortcut to code folding in NetBeans. This answer extends @krtek 's answer. To achieve this follow the steps:

    1. Go to Tools> Options> Editor> Code templates

    2. Click New, enter "cf" as the abbreviation, then enter the following code as the expanded text:

         // <editor-fold defaultstate="collapsed" desc=" ${DESCRIPTION} ">
            ${selection line}${cursor}
            // </editor-fold>
    
    1. In the description tab, enter "Code folding", and click Ok.

    Now, if you select multiple lines of text in the editor, you will get the "light bulb" icon in the margin. Click it, and you'll get the option "Surround with Code folding". Select it, enter a description and you're done.

    For reference see this link: reference

    0 讨论(0)
  • 2021-01-31 15:02

    K.I.S.S. solution:

    { // region name, description, etc.
       code;
    }
    

    Or, comment above the brace... Braces don't need no function, man.

    0 讨论(0)
  • 2021-01-31 15:07

    If you are using notepad++ you can define that sort of thing with the ide in user defined language dialog, and since good old region starts with the pound sign, it works great because the pound "#" is actually one way to mark in php a comment. But, I tried it in version 6.6.6 of notepad++ and it already has #region #endregion functionality already no need to do anything.

    0 讨论(0)
提交回复
热议问题