Collapse only methods
Followed by 4 people
Answered
Hi,
I think it would be nice to have a menu option and/or keyboard shortcut to collapse only the methods (or any other hierarchy level) in an open file, so as to see clearly and easily navigate a neat list of the uppermost elements that form a class.
As of today, you can collapse everything at certain predefined levels, which would of course include methods, but doing so also recursively collapses everything inside the methods themselves, which forces you to manually unfold any conditionals, etc. inside the method once you unfold it.
Please sign in to leave a comment.
Hi,
If I've understood you correctly, 'Expand Recursively' action may help. Put cursor on the method and press 'Ctrl+Alt+NumPad Plus'(Visual Studio keymap) to expand the method and everything inside of it. More info on folding actions in Rider: https://www.jetbrains.com/help/rider/2017.1/Code_Folding.html
Hope it helps,
Julia
That does help! I hadn't tried putting the cursor on the method, I just pressed the keyboard shortcut and everything in the file collpased. Thanks Julia.
You are welcome!
Please add an easier version of this. I want to be able to expand all methods recursively
vs code has fold level 1, intellij does not have
Serkanozel380,
Please take a look at the new Rider docs on folding code elements: https://www.jetbrains.com/help/rider/Code_Folding.html#folding_menu. We have added new actions there. Does any of them suits you? If not, could you please provide a code example with expected and actual results after you expand it?
Julia Vaseva let me elaborate more:
Think about this code (typescript, language does not matter at all)
after vscode's fold level 1
Serkanozel380,
For C# Rider has a nice action named `Collapse to definitions` (Code -> Folding -> Collapse to Definitions), which collapses methods, but not their contents. To expand all of them back, use `Expand all` action. Unfortunately, other languages doesn't support it. Here is the feature request for other languages: https://youtrack.jetbrains.com/issue/IDEA-231351. Please feel free to add a comment and upvote.
Julia Vaseva
Here is an example of code from VueJs
I would like to be able to collapse to level 1 so that only the methods in "methods" are collapsed, without the loops and conditions being collapsed when I open a method.
A bit like PHP's collapse which only collapses the method but not the contents of the method when the method is opened.
Jeremy
Thank you for the code example. I have added it as an internal comment to IDEA-231351 feature request so that the developers team can see it. Please upvote the issue in order to demonstrate additional interest and bring increased awareness to the issue.