背景:
阅读新闻

android studio 中类似VS的代码折叠功能Region

  作者: 今日评论: [字体: ]

慢慢适应,然后更改设置keymap之后,用起来越来越有vs的fu了

http://www.myandroidsolutions.com/2014/06/21/android-studio-intellij-idea-code-regions/

If you ever worked with Xcode then you must know the power of “#pragma mark” macro. You could just define regions of code using that and sometimes it helps when you have classes that can get a bit big or if you just want to have a nice structure of your class.

Well you can do that on Android Studio or IntelliJ IDEA or any of JetBrains’s IDE.

Using the steps below you can group your code and name the group however you like and also contract/expand the groups of code.

Code without grouping

Code without grouping feature

1. Open the IDE you are using

2. Select the code you want to group like in the image below

Group selection

Code selection

3. Press Ctrl + Alt + T and select the “region .. end region comments”

Group selection dialog

Group selection dialog

4. Now the code is surrounded with “//region” / “//endregion” lines, you can see that the region can be fold-able

Initial code region

Initial code region

5. You can now edit the description of your group

Collapsed Group with description

Collapsed Group with description

6. You can easily see the code within your group without having to expand the group, just hover the group description with the mouse pointer

Group code preview
来源:
录入日期:[2016/05/05 2:16:00]
收藏 推荐 打印 | 录入:mikebai | 阅读:
文章评论      
正在加载评论列表...
评论表单加载中...