Xcode Swift代码折叠/折叠 [英] Xcode Swift code folding/collapse

查看:634
本文介绍了Xcode Swift代码折叠/折叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我们可以使用"Shift + Alt + Cmd + Left"来折叠/折叠Xcode中的swift代码,但是谁能告诉我如何折叠/折叠仅用于功能? 不是属性? 或其他替代方式?

I know we can use "Shift + Alt + Cmd + Left" to fold/collapse swift code in Xcode, but can anyone tell me how to fold/collapse for functions only? Not properties? Or any alternative way?

默认的折叠方法可以完成任务,但实际上也向我们隐藏了非常重要的信息……

The default folding method does the job, but actually also hide very important information from us......

推荐答案

Xcode 10 :

Xcode 10增加了对代码折叠的支持,包括:

Xcode 10 has increased support for code folding, including:

  1. 新的代码折叠功能区,显示编辑器中所有多行可折叠的代码块
  2. 编辑器中折叠代码的新样式,可让您编辑带有折叠代码的行
  3. 支持折叠用花括号括起来的任何代码块
  4. 支持从折叠功能区,结构化选择或
  5. 中折叠代码块
  1. A new code folding ribbon showing all of the multi-line foldable blocks of code in the editor
  2. A new style for folded code in the editor that allows you to edit lines with folded code
  3. Support for folding any block of code enclosed in curly braces
  4. Support for folding blocks of code from the folding ribbon, from structured selection, or from the

菜单栏►编辑器►代码折叠►折叠菜单项

Menubar ► Editor ► Code Folding ► Fold menu item

看看这个快照:

根据beta版本说明,在Xcode 9 beta 1(现已正在运行)的Xcode 9 Beta5中禁用了代码折叠:

Code folding was disabled in Xcode 9 beta 1, which is working now, in Xcode 9 Beta5 according to beta release note: Resolved in Xcode 9 beta 5 – IDE

方法如下:

  1. 按住键盘上的 (命令)按钮,然后在任何(开始或结束)花括号上移动/悬停鼠标光标.它将自动突出显示区域.
  2. 保持(按住) (命令)按钮处于按下状态,然后单击突出显示的区域.它将启用带有 Fold 选项的快速菜单弹出窗口.
  3. 从菜单列表中选择 Fold .它将折叠您的代码并显示3个点,折叠/覆盖整个块.
  4. 现在,要再次展开代码块,请释放 (命令)按钮,然后单击3个点来折叠一个代码块.

为便于理解,请查看以下快照:


所有的键盘快捷键都可以使用.


It's all keyboard short cuts are also working.

Fold                          ⌥ ⌘ ←      option + command + left arrow
Unfold                        ⌥ ⌘ →      option + command + right arrow
Unfold All                    ⌥ U        option + U
Fold Methods & Functions      ⌥ ⌘ ↑      option + command + up arrow
Unfold Methods & Functions    ⌥ ⌘ ↓      option + command + down arrow
Fold Comment Blocks           ⌃ ⇧ ⌘ ↑    control + shift + command + up
Unfold Comment Blocks         ⌃ ⇧ ⌘ ↓    control + shift + command + down
Focus Follows Selection       ⌃ ⌥ ⌘ F    control + option + command + F
Fold All                      ⌘ ⌥ ⇧ ←    command + option + shift + left
Unfold All                    ⌘ ⌥ ⇧ →    command + option + shift + left


Xcode菜单中的代码折叠选项:

菜单栏►编辑器►代码折叠►此处是代码折叠选项列表"

Menubar ► Editor ► Code Folding ► "Here is list of code folding options"

这是裁判快照:

Xcode快捷方式列表中的相同选项:

菜单栏►Xcode►首选项►键绑定►此处是代码折叠快捷键的列表"

Menubar ► Xcode ► Preferences ► Key Bindings ► "Here is list of code folding short-keys"

这篇关于Xcode Swift代码折叠/折叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆