简体   繁体   English

保持代码崩溃 - Eclipse IDE

[英]Keeping Code Collapsed - Eclipse IDE

Just curious if there's a setting somewhere in Eclipse to keep blocks of code collapsed when the class is opened? 只是好奇是否有一个设置在Eclipse的某个地方,以便在打开类时保持代码块崩溃? It's just I'll collapse methods then when the class is re-opened, everything is expanded. 只是我会崩溃方法然后当类重新打开时,一切都被扩展。

Thanks 谢谢

In Windows > preferences : Windows > preferences

Java > editor > folding : check all, click apply & then OK . Java > editor > folding :选中全部,单击“ apply ”,然后单击“ OK

Maybe this helps: Ctrl + Shift + NUM_KEYPAD_DIVIDE collapse all methods in a java class. 也许这会NUM_KEYPAD_DIVIDE帮助: Ctrl + Shift + NUM_KEYPAD_DIVIDE折叠java类中的所有方法。

Eclipse源代码折叠

Source 资源

Yes . 是的 From the eclipse official documentation : 日食官方文档

You can specify which regions are folded by default when an editor is opened. 您可以在打开编辑器时指定默认折叠的区域。 Have a look at the Opens the folding preference page Java >Editor > Folding preference page to customize this. 查看打开折叠首选项页面Java>编辑器>折叠首选项页面以自定义此选项。

在此输入图像描述

Just click all the checkboxs .Then whenever a .java file is open in the java editor , everything will be collapsed. 只需单击所有复选框。然后,只要在java编辑器中打开.java文件,所有内容都将被折叠。

Not sure if this options is the new feature for eclipse indigo version (3.7) , so you may have to update your eclipse to indigo if you use older version but cannot find this option. 不确定这个选项是否是eclipse indigo版本(3.7)的新功能,所以如果你使用旧版本但是找不到这个选项,你可能不得不将你的eclipse更新为indigo。

Yes, you can set the options what to fold on file open. 是的,您可以设置选项在打开文件时折叠的内容。

You can find it at Settings->Editor->Folding 您可以在Settings-> Editor-> Folding中找到它

It features a resonable selection of folding options. 它具有合理的折叠选择。

I'm not aware of a solution, but let me tell you how I work - maybe this is a solution for you as well: 我不知道解决方案,但让我告诉你我的工作方式 - 也许这也是你的解决方案:

  1. Enable "Only show the selected Java element" . 启用“仅显示选定的Java元素” The editor will only show the element (method) you selected (see screenshot). 编辑器只显示您选择的元素(方法)(见截图)。

  2. While editing a file use either the Outline view or CTRL + O to navigate through the class file. 编辑文件时,使用“ 大纲”视图或CTRL + O来浏览类文件。

Btw: I disabled all folding options as the above approach just works best for me. 顺便说一句:我禁用了所有折叠选项,因为上述方法对我来说效果最好。 Sadly, I'm not aware of a shortcut to enable/disable the "Only show the selected Java element". 遗憾的是,我不知道启用/禁用“仅显示所选Java元素”的快捷方式。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM