【发布时间】:2016-09-25 15:42:26
【问题描述】:
有人在 Xcode 8 中遇到代码折叠问题吗?每次我折叠GameScene.swift(或任何其他文件),切换到例如AppDelegate.swift,然后切换回GameScene.swift(之前折叠),它就会展开。
【问题讨论】:
标签: xcode code-folding
有人在 Xcode 8 中遇到代码折叠问题吗?每次我折叠GameScene.swift(或任何其他文件),切换到例如AppDelegate.swift,然后切换回GameScene.swift(之前折叠),它就会展开。
【问题讨论】:
标签: xcode code-folding
Xcode 不幸的是既不存储也不记得代码折叠。它实际上在失去对该文件的焦点后重置折叠的部分。
由于代码折叠一直被重置,所以我个人使用这种重新折叠的方式:
折叠所有方法: Shift + Alt + Cmd +
将光标放在所需的方法上并通过单击或使用快捷方式展开它: Alt + Cmd + ->右
【讨论】:
使用 Xcode-9,这个问题得到了解决。 Xcode 9 Editor 会记住并保存代码折叠。
您在上次源代码构建/保存之前完全折叠/已经折叠的代码会在文档/文件关闭时自动存储。当您下次打开文档/文件时,它将与(折叠)时一样可见。
您无需执行任何操作(Xcode 工具栏中没有任何选项可以启用或禁用)来保存您的代码折叠。
以下是一些用于代码折叠的键盘快捷键:
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
【讨论】: