我想在Eclipse中使用区域进行代码折叠;在Java中怎么做到呢?
c#中的一个例子:
#region name
//code
#endregion
我想在Eclipse中使用区域进行代码折叠;在Java中怎么做到呢?
c#中的一个例子:
#region name
//code
#endregion
当前回答
没有这样的标准对等物。一些ide(例如Intellij或Eclipse)可以根据所涉及的代码类型(构造函数、导入等)进行折叠,但没有像#region这样的ide。
其他回答
Jet Brains IDEA拥有这一功能。你可以使用热键环绕(ctrl + alt + T),这只是IDEA功能。
区域是这样的:
//region Description
Some code
//endregion
自定义代码折叠功能可以使用CoffeeScript代码折叠插件添加到eclipse。
这已被测试用于月食Luna和Juno。以下是步骤
Download the plugin from here Extract the contents of archive Copy paste the contents of plugin and features folder to the same named folder inside eclipse installation directory Restart the eclipse Navigate Window >Preferences >Java >Editor >Folding >Select folding to use: Coffee Bytes Java >General tab >Tick checkboxes in front of User Defined Fold Create new region as shown: Restart the Eclipse. Try out if folding works with comments prefixed with specified starting and ending identifiers
你也可以在这个博客上下载存档和查找步骤。
我刚从c#转到java,遇到了同样的问题,最好的和准确的区域替代方案如下(在Android Studio工作,不知道intelliJ):
//region [Description]
int a;
int b;
int c;
//endregion
快捷方式如下:
1-选择代码
2-按下ctrl + alt + t
3-按c并写下你的描述
Android Studio(或IntelliJ IDEA)中最快的方法
突出显示要围绕它的代码 按CTRL + Alt + t 按c ==>输入描述 享受
最好的方法
//region DESCRIPTION_REGION
int x = 22;
// Comments
String s = "SomeString";
//endregion;
提示:将";"放在"endregion"的末尾