如何最小化 Eclipse 中的代码区域?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/383784/
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-19 13:27:29  来源:igfitidea点击:

How to minimize code area in Eclipse?

eclipse

提问by Stella

There is a nice feature in Visual Studio: you can create special code areas which can be minimized just as class methods in Eclipse are minimized. Like:

Visual Studio 中有一个很好的功能:您可以创建可以最小化的特殊代码区域,就像最小化 Eclipse 中的类方法一样。喜欢:

#region

//some code

#endregion

Is there a way do make such pleasant feature in Eclipse?

有没有办法在 Eclipse 中制作这样令人愉快的功能?

回答by Mitch

It's called "collapse all", click on the editor view that you want to collapse all your methods in go to help> key assist...> double click "collapse all">, everything is collapsed

它被称为“全部折叠”,单击要折叠所有方法的编辑器视图转到帮助> 关键辅助...> 双击“全部折叠”>,一切都已折叠

回答by arthi

Click on ' - (minus)' symbol on the side of the editor, Right click on minus symbol , Go to folding / Collapse All

单击编辑器侧面的“-(减号)”符号,右键单击减号,转到折叠/全部折叠

Keyboard shortcut : Ctrl+Shift+NumbPad_Divide

键盘快捷键:Ctrl+Shift+NumbPad_Divide

回答by Stefan Schmidt

If you mean by minimizing folding, then I don't think Eclipse has the folding option you want. When I look at the eclipse folding options it tells me that it can fold

如果您的意思是最小化折叠,那么我认为 Eclipse 没有您想要的折叠选项。当我查看 eclipse 折叠选项时,它告诉我它可以折叠

  • Comments
  • Header Comments
  • Inner Types
  • Members
  • Imports
  • 注释
  • 标题注释
  • 内部类型
  • 会员
  • 进口

If you don't mean folding, then I'm sorry for the confusion.

如果你的意思不是折叠,那么我很抱歉造成混乱。

回答by Shan Xeeshi

First check Folding is enable or disable if enabled then you can minimize or collapse code and expand code. You can check Folding through

首先检查折叠是否启用或禁用,如果启用,则您可以最小化或折叠代码并展开代码。您可以检查折叠通过

Folding is configured under Window -> Preferences -> Java -> Editor ->Folding

在Window -> Preferences -> Java -> Editor ->Folding 下配置折叠

Please check Enable Folding if its unchecked

如果未选中,请选中启用折叠

Now you can minimize your code

现在你可以最小化你的代码

Collapse All (all functions on page) : Ctrl+Shift+NumbPad_Divide

全部折叠(页面上的所有功能):Ctrl+Shift+NumbPad_Divide

Expand All (all function on page) : Ctrl+Shift+NumbPad_Mulitply

展开全部(页面上的所有功能):Ctrl+Shift+NumbPad_Mulitply

Collapse One function : Ctrl+NumbPad_Minus

折叠一功能:Ctrl+NumbPad_Minus

Expand One Function : Ctrl+NumbPad_Plus

展开一项功能:Ctrl+NumbPad_Plus

回答by Zain Ullah Muhammad

Java Equivalent to #region in c#

Java 相当于 c# 中的 #region

Check the second answer

检查第二个答案

//region MY REGION

//区域我的区域

code here

代码在这里

//endregion

//结束区域

回答by raydenxxx

There are some plugins for this, like "Coffee Bytes Java Folding" for Eclipse. Other IDE like Netbeans as an native equivalent.

为此有一些插件,例如 Eclipse 的“Coffee Bytes Java Folding”。其他 IDE(如 Netbeans)作为本机等价物。

It's really IDE dependent in Java, not implemented in the language like in C# for example.

它在 Java 中确实依赖于 IDE,而不是像在 C# 中那样用语言实现。

回答by drdanielfc

  • Heres how I do it:

    1. Create an empty class called Blank
    2. Use this outline for your code:

    Blank b = new Blank() { public void myCode() { /Insert code here/ } }; b.myCode();

  • 这是我如何做到的:

    1. 创建一个名为 Blank 的空类
    2. 将此大纲用于您的代码:

    Blank b = new Blank() { public void myCode() { /在此处插入代码/ } }; b.myCode();