Jetbrains / Intellij keyboard shortcut to collapse all methods

匿名 (未验证) 提交于 2019-12-03 02:44:02

问题:

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){...} 

回答1:

You may take a look at intellij code folding shortcuts. I guess that Ctrl+Shift+- is exactly what you need.



回答2:

The above suggestion of Ctrl+Shift+- code folds all code blocks recursively. I only wanted to fold the methods for my classes. 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.)



回答3:

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



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!