IntelliJ IDEA-为循环和/或if/else语句折叠 [英] IntelliJ IDEA - Fold for loop and/or if/else statements

查看:1309
本文介绍了IntelliJ IDEA-为循环和/或if/else语句折叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想拥有一种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?

推荐答案

您可以折叠和展开:

You can fold and unfold:

  • 代码块,即由匹配的一对大括号{}包围的代码片段.

  • Code blocks, i.e. code fragments surrounded by a matched pair of curly braces {}.

要折叠代码块,请将光标置于该代码块内,然后选择 Code |.折叠折叠代码块或按 + + .(mac)或 ctrl + + .(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 ctrl++. (Linux / Windows).

注意代码折叠适用于关键字if/while/else/for/try/except/finally/with至少两个语句.

Note Code folding works for the keywords if/ while/ else/ for/ try/ except/ finally/ with in case of at least two statements.

请参阅: https://www.jetbrains.com/help/idea/2016.3/code-folding.html

这篇关于IntelliJ IDEA-为循环和/或if/else语句折叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆