如何在 Eclipse 中折叠代码块?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3450880/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 19:33:53  来源:igfitidea点击:

How to collapse blocks of code in Eclipse?

eclipsecode-editor

提问by Cristian

Some days ago my Eclipse was working fine and a +/- appeared in every block that could be collapsed (functions, classes, etc.)... but now it does appear, and I don't know how to activate that feature again.

几天前,我的 Eclipse 工作正常,并且 +/- 出现在每个可以折叠的块(函数、类等)中……但现在它确实出现了,我不知道如何再次激活该功能.

It's Eclipse Helios, running on a Gentoo Linux box.

它是 Eclipse Helios,在 Gentoo Linux 机器上运行。

回答by IanH

Preferences -> C++ -> Editor -> Folding ?

首选项 -> C++ -> 编辑器 -> 折叠 ?

Make a right click in the editor window and go to preferences there, then only the editor-relevant section of the preferences dialog will appear. This works for JDT, CDT etc...

在编辑器窗口中右键单击并转到那里的首选项,然后只会出现首选项对话框中与编辑器相关的部分。这适用于 JDT、CDT 等...

回答by Kenny Peng

You can do ( Ctrl+ Numpad_Divide) to enable folding.
Also if you Right Clickon the area where the +or -was supposed to be, you can see there is a folding option.

您可以执行 ( Ctrl+ Numpad_Divide) 以启用折叠。
此外,如果您Right Click+-应该在的区域,您可以看到有一个折叠选项。

回答by Chris Lercher

Try this option: Preferences > Java > Editor > Folding > Enable folding

试试这个选项:首选项 > Java > 编辑器 > 折叠 > 启用折叠

回答by mmrs151

For Python it is as follows:

对于 Python,它如下所示:

  • collapse all 1 level: Ctrl+9
  • expand all 1 level: Ctrl+0
  • collapse current: Ctrl+-
  • expand current: Ctrl++
  • 折叠所有 1 个级别:Ctrl+9
  • 展开所有 1 个级别:Ctrl+0
  • 崩溃电流:Ctrl+-
  • 展开电流:Ctrl++

Hope that helps.

希望有帮助。

回答by Joolah

To collapse all code blocks Ctrl+ Shift+ /

折叠所有代码块 Ctrl+ Shift+/

To expand all code blocks Ctrl+ Shift+ *

展开所有代码块 Ctrl+ Shift+*

pydev:

pydev:

To collapse all code blocks : Ctrl+ 0

折叠所有代码块: Ctrl+0

To collapse all code blocks : Ctrl+ 9

折叠所有代码块: Ctrl+9

Is there a way to collapse all code blocks in Eclipse?

有没有办法折叠 Eclipse 中的所有代码块?

by @partizanos and @bummi

通过@partizanos 和@bummi

回答by James Moore

In Preferences, you'll find General > Keys. It's for setting your keyboard shortcuts.

在“首选项”中,您会找到“常规”>“键”。它用于设置键盘快捷键。

What I use it for more often, though, is to find stuff in Eclipse. You should see an input box labelled "type filter text." It's as close as Eclipse comes to a search feature for every Eclipse command.

不过,我更经常使用它的目的是在 Eclipse 中查找内容。您应该会看到一个标有“类型过滤器文本”的输入框。它就像 Eclipse 为每个 Eclipse 命令提供搜索功能一样。

回答by Starkey

I assume you are using Java, but look under the settings for your particular language.

我假设您使用的是 Java,但请查看您的特定语言的设置。

Under the Window menu, select Preferences.

在窗口菜单下,选择首选项。

Under Java->Editor->Folding. Select "Enable Folding".

在 Java->Editor->Folding 下。选择“启用折叠”。

回答by Brig

If you want folding an all your editors, I found you can enable Folding in

如果您想折叠所有编辑器,我发现您可以启用折叠

Preferences > Editors > Structured Text Editors

首选项 > 编辑器 > 结构化文本编辑器

Enable Folding

启用折叠

回答by Kim Wilson

In CFEclipse: Preferences > CFEclipse > Editor > Code Folding > Initially Collapse column, you can uncheck to see all expanded when opening, or check all boxes to close all when opening a file.

在 CFEclipse 中:首选项 > CFEclipse > 编辑器 > 代码折叠 > 初始折叠列,您可以取消选中以在打开时查看所有展开,或选中所有框以在打开文件时全部关闭。

回答by Akshay Vijay Jain

I was using salesforce apex classes with Eclipse Neon 3.3 for Java.
I found an option "define folding region" on right click in the editor, I selected the block of code i wanted to collapse and selected this property for that code. Now I am seeing + and - symbol to expand and collapse that block of code

我在 Eclipse Neon 3.3 for Java 中使用了 salesforce apex 类。
我在编辑器中右键单击找到了一个选项“定义折叠区域”,我选择了我想要折叠的代码块并为该代码选择了这个属性。现在我看到 + 和 - 符号来展开和折叠该代码块