Java 用于折叠/展开方法的 NetBeans 快捷键
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2965200/
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
NetBeans shortcut key for collapsing/expanding a method
提问by Stefanos Kargas
JAVA - NETBEANS
JAVA - 网豆
This is an IDE question
这是一个IDE问题
I am always working with collapsed methods, because I want to be able to see my methods all together. This is a little time consuming because I have to use the mouse to scroll up to the declaration of the method and click on the - (minus) icon. And then respectively go to the method I want to work on and click on the + (plus) icon.
我总是使用折叠方法,因为我希望能够一起查看我的方法。这有点耗时,因为我必须使用鼠标向上滚动到方法的声明并单击 -(减号)图标。然后分别转到我要处理的方法并单击+(加号)图标。
Is there a way through a keyboard shortcut to do the collapse (and respectively the expand)?
有没有办法通过键盘快捷键进行折叠(以及分别展开)?
采纳答案by Peter Tillemans
I copied a piece from http://wiki.netbeans.org/KeymapProfileFor60.
我从http://wiki.netbeans.org/KeymapProfileFor60复制了一段。
The first option is for Win/Lin and the second for Mac.
第一个选项适用于 Win/Lin,第二个选项适用于 Mac。
Collapse (hide) a block Ctrl + Minus Cmd + Minus
Collapse (hide) a block Ctrl + NumPad Minus
Collapse (hide) all code blocks Ctrl + Shift + NumPad Minus Cmd + Shift + Minus
Expand a Collapsed Block (expand-fold) Ctrl + Plus Cmd + Plus
Expand a Collapsed Block (expand-fold) Ctrl + NumPad Plus
Expand a Collapsed Block (expand-fold) Ctrl + Equals Cmd + Equals
Expand all code blocks (expand-all-folds) Ctrl + Shift + NumPad Plus
Expand all code blocks (expand-all-folds) Ctrl + Shift + Plus Cmd + Shift + Plus
Expand all code blocks (expand-all-folds) Ctrl + Shift + Equals Cmd + Shift + Equals
回答by JRL
Just to offer an alternative, have you considered using the Navigator View to navigate within the members instead? I usually just leave all methods uncollapsed, and double click on the method in the Navigator view to go to that method. What's nice about the Navigator View are the icons which provide visual indicators of the type and visibility of methods and fields.
只是提供一个替代方案,您是否考虑过使用导航器视图在成员内导航?我通常只是不折叠所有方法,然后在导航器视图中双击该方法以转到该方法。导航器视图的优点在于提供了方法和字段的类型和可见性的可视指示符的图标。
回答by AmanicA
The best workaround I've found sofar is to right-click in the white space next to the file tree and then click on "Collapse All"
迄今为止我发现的最佳解决方法是右键单击文件树旁边的空白区域,然后单击“全部折叠”
回答by JasonRobinson
The navigator view does not show loop blocks, logic blocks, etc. So there is no way to collapse that section under the "if this" so you can focus on the "else that" section.
导航器视图不显示循环块、逻辑块等。因此无法折叠“if this”下的该部分,因此您可以专注于“else that”部分。
NetBeans only supports collapsing functions/methods (Java) or collapsing based on their XML formatted comment strings (a terrible solution that is IDE specific and leaves traces of your IDE all over your code).
NetBeans 仅支持折叠函数/方法 (Java) 或基于其 XML 格式注释字符串的折叠(这是一个糟糕的解决方案,它是 IDE 特定的,并且在整个代码中都留下了 IDE 的痕迹)。
回答by SirMedvind
Right click the window -> Code Folds -> Collapse Allor Ctrl+Shift+MinusSounds like what you ar looking for
右键单击窗口 -> 代码折叠 -> 全部折叠或Ctrl+Shift+Minus听起来像您正在寻找的
回答by shivakumar hk
To set default collapsing in netbean tool click Tools->Option->Editor->Folding, enable checkboxes
要在 netbean 工具中设置默认折叠,请单击工具->选项->编辑器->折叠,启用复选框