Prevent Comments Block Folding

Hi All,

 

I writing a post to ask if there is a way, or plugin which allow you to select which block you want to fold when you use shortcut.

I would like to prevent folding of comments blocks.

For me, if comments are folded, they are useless.

See below a demonstration of a software i use which allow it. I wand to leave this online software to go on phpStorm.

(I know my comments are not PSR-2, but i also want for PSR-2 Comments)

Thanks a lot.

2
6 comments

Hi there,

Unfortunately it's not that obvious (to me at very least) what exactly you wish to be done.

I mean:

  • The default code folding rules (that are applied on file opening) can be set at "Settings/Preferences | Editor | General | Code Folding"
  • Available code-folding actions can be seen at "Code | Folding"
  • Shortcuts can be changed at "Settings/Preferences | Keymap"

Therefore:

  • if you wish to have all method bodies collapsed but have comments left in expanded state -- that can be configured as default folding behaviour (applies on file opening)
  • if you want to collapse/expand it at any time ... then I guess the sequence would be:
  • A) collapse all
  • B) use "Code | Folding | Expand doc comments"
  • ... but I'm just not sure here if such comments (block comments that applied to a single line only) will be treated correctly (as part of some bigger comment block)...
0

Hi Andriy Bazanov,


Thank you for your reply. Your are awesone. I didn't thought to use macro feature to realize that.

See below what i get with macros. The result is the same as what i had in Codeanywhere Version 5 !

So i have all features which i looking for to change developping software in favor of local client.

 

(In codeanywhere, i use tabsize = 3, so the presentation is broken in demonstration)




Thanks again for your support.

 

Best Regards,

Nicolas DUPRE @Neoblaster.

0

Hello Andriy,

Could you please explain how I can fold only methods and not comments? Specifically, here's a screenshot. As you can see, one-line comments randomly appear for folding and unfolding. I don't want this. I want only method names or code blocks to be folded or unfolded. I have attached screenshot herewith.

0

@VB

All available options for auto code folding are located at "Settings/Preferences | Editor | General | Code Folding".

Sadly I cannot say why you have a folding block there for those 4 consequent commented lines (it does not seem to happen to me in PHP), but I personally would understand why it may happen (consequent comments mean unneeded code or actually related comments).

My best guess right now -- maybe you are adding such folding yourself? e.g. selecting that code and then hitting shortcut for "Code | Folding | Fold Selection" ?

0

In my case I wanted the code to not fold for every team member not just me (we all use PHPStorm), the workaround I found is to put the comments this way, which prevents it from being folded by default (or so it seems):

0

@Neo-blaster

How did you make the video gif?

That seems very useful here.

0

Please sign in to leave a comment.