问题描述
我很想拥有一种IntelliJ方式,可以折叠for
循环和if/else
语句.但是,我似乎找不到自动执行此操作的方法.我知道您可以使用//region
和//endregion
注释,也可以使用Ctrl + Shift +周期手动进行操作,但是有一种方法可以避免所有这些问题,并且可以像方法或类一样将其折叠起来,而无需执行所有操作其他东西?
I'd love to have a way of IntelliJ letting me fold for
loops and if/else
statements. But, I can't seem to find a way to do it automatically. I know you can use the //region
and //endregion
comments, or that you can do it manually with Ctrl+Shift+period, but is there a way to avoid all that and have it fold like methods or classes, without doing all that other stuff?
推荐答案
-
代码块,即由匹配的一对大括号
{}
包围的代码片段.
Code blocks, i.e. code fragments surrounded by a matched pair of curly braces
{}
.
要折叠代码块,请将光标置于该代码块内,然后选择 Code |.折叠折叠代码块或按 + + (mac)或 + + (Linux/Windows).
To collapse a code block, place the cursor within that block and then select Code | Folding | Fold Code Block or press ++ (mac) or ++ (Linux / Windows).
请参阅: https://www.jetbrains.com/help/idea/2016.3/code-folding.html
这篇关于IntelliJ IDEA-为循环和/或if/else语句折叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!