[intellij-idea] JetBrains / IntelliJ keyboard shortcut to collapse all methods

I'm working on some legacy code that has a class that is 10,000+ lines of code and has 100s of methods. Is there a shortcut for any JetBrains IDE (since the shortcut would likely be shared across all of them) to collapse all the methods / functions so that only the method signatures are shown?

Something like this:

public String myMethod(String arg1, int arg2){...}

public String mySecondMethod(String arg1, int arg2){...}

This question is related to intellij-idea ide phpstorm keyboard-shortcuts

The answer is


In Rider, this would be Ctrl +Shift+Keypad *, 2

But!, you cannot use the number 2 on keypad, only number 2 on the top row of the keyboard would work.


You Can Go To setting > editor > general > code folding and check "show code folding outline" .


go to menu option Code > Folding to access all code folding related options and their shortcuts.


@precastic's answer above is, imo, the right idea.

Worth noting that in IDEA 2018.2 (and surely other nearby versions) there are default keyboard shortcuts for this: (showing Mac, see Code > Folding > Expand All to Level for your system):

Cmd+Option+Keypad *, 1 - expand all to level 1
Cmd+Option+Keypad *, 2 - expand all to level 2
...
Cmd+Option+Keypad *, 5 - expand all to level 5

Note: these are "second stroke" shortcuts. First press Cmd+Option+*, then release, then hit the number you want.


The above suggestion of Ctrl+Shift+- code folds all code blocks recursively. I only wanted to fold the methods for my classes.

Code > Folding > Expand all to level > 1

I managed to achieve this by using the menu option Code > Folding > Expand all to level > 1.

I re-assigned it to Ctrl+NumPad-1 which gives me a quick way to collapse my classes down to their methods.

This works at the 'block level' of the file and assumes that you have classes defined at the top level of your file, which works for code such as PHP but not for JavaScript (nested closures etc.)


Examples related to intellij-idea

IntelliJ: Error:java: error: release version 5 not supported Has been compiled by a more recent version of the Java Runtime (class file version 57.0) Error: Java: invalid target release: 11 - IntelliJ IDEA IntelliJ can't recognize JavaFX 11 with OpenJDK 11 Error: JavaFX runtime components are missing, and are required to run this application with JDK 11 ERROR Source option 1.5 is no longer supported. Use 1.6 or later Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 How to configure "Shorten command line" method for whole project in IntelliJ intellij idea - Error: java: invalid source release 1.9 Failed to resolve: com.google.android.gms:play-services in IntelliJ Idea with gradle

Examples related to ide

How can I view the Git history in Visual Studio Code? How to ignore a particular directory or file for tslint? How do I completely rename an Xcode project (i.e. inclusive of folders)? Where is the visual studio HTML Designer? How to disable gradle 'offline mode' in android studio? Android studio Error "Unsupported Modules Detected: Compilation is not supported for following modules" Android Studio was unable to find a valid Jvm (Related to MAC OS) QtCreator: No valid kits found Difference between WebStorm and PHPStorm package android.support.v4.app does not exist ; in Android studio 0.8

Examples related to phpstorm

Difference between WebStorm and PHPStorm Cannot ignore .idea/workspace.xml - keeps popping up JetBrains / IntelliJ keyboard shortcut to collapse all methods Can IntelliJ IDEA encapsulate all of the functionality of WebStorm and PHPStorm through plugins? Word wrapping in phpstorm How to display hidden characters by default (ZERO WIDTH SPACE ie. &#8203) How to make phpstorm display line numbers by default? How do you debug PHP scripts?

Examples related to keyboard-shortcuts

Collapse all methods in Visual Studio Code Is there a keyboard shortcut (hotkey) to open Terminal in macOS? Jupyter/IPython Notebooks: Shortcut for "run all"? Any way (or shortcut) to auto import the classes in IntelliJ IDEA like in Eclipse? How do I duplicate a line or selection within Visual Studio Code? How do I search for files in Visual Studio Code? OS X Terminal shortcut: Jump to beginning/end of line window.close() doesn't work - Scripts may close only the windows that were opened by it Comment shortcut Android Studio Column/Vertical selection with Keyboard in SublimeText 3