如何折叠 Xcode 中的所有方法?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2834605/
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
How to collapse all methods in Xcode?
提问by Omer
How to collapse all methods in a class in Xcode?
如何在 Xcode 中折叠一个类中的所有方法?
Collapsing one by one is not an option anymore.
一个一个地倒塌不再是一种选择。
回答by Joseph
As of Xcode 4 it seems to have changed.
从 Xcode 4 开始,它似乎发生了变化。
command-alt-shift-left arrowwill do the trick...
command- alt- shift-left arrow会做的伎俩...
To fold/unfold current methods or if
structures use:
要折叠/展开当前的方法或if
结构,请使用:
Fold: command-alt-left arrow
折叠:command- alt-left arrow
Unfold: command-alt-right arrow
展开:command- alt-right arrow
回答by Krunal
Updates in Xcode 10
Xcode 10 has increased support for code folding, including:
Xcode 10 增加了对代码折叠的支持,包括:
- A new code folding ribbon showing all of the multi-line foldable blocks of code in the editor
- A new style for folded code in the editor that allows you to edit lines with folded code
- Support for folding any block of code enclosed in curly braces
- Support for folding blocks of code from the folding ribbon, from structured selection, or from the
- 显示编辑器中所有多行可折叠代码块的新代码折叠功能区
- 编辑器中折叠代码的新样式,允许您编辑带有折叠代码的行
- 支持折叠花括号中的任何代码块
- 支持从折叠功能区、结构化选择或从
Menubar ? Editor ? Code Folding ? Fold menu item
菜单栏 ?编辑?代码折叠 ? 折叠菜单项
Look at this snapshot:
看看这个快照:
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
代码折叠在 Xcode 9 beta 1 中被禁用,它现在正在运行,在 Xcode 9 Beta5 中根据测试版发布说明:在 Xcode 9 beta 5 – IDE 中解决
Here is how:
方法如下:
- Press and hold ?(command) button in keyboard and move/hover mouse cursor on any (start or end) braces. It will automatically highlight, block area.
- Keep (hold) ?(command) button in pressed condition and click on highlighted area. It will enable quick menu popover window with
Fold
option. - Select
Fold
from menu list. It will fold your code and shows 3 dots, folding/covering entire block. - Now, to again unfold your code block, release ?(command) button and click on 3 dots folding a block.
- 按住?键盘上的(命令)按钮并将鼠标光标移动/悬停在任何(开始或结束)大括号上。它会自动突出显示,阻止区域。
- 保持(按住)?(命令)按钮处于按下状态,然后单击突出显示的区域。它将启用带有
Fold
选项的快速菜单弹出窗口。 Fold
从菜单列表中选择。它将折叠您的代码并显示 3 个点,折叠/覆盖整个块。- 现在,再次展开您的代码块,释放?(命令)按钮并单击折叠块的 3 个点。
For easy understanding, look at this snapshot:
为了便于理解,请看这张快照:
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
Code folding options from Xcode Menu:
Xcode Menu 中的代码折叠选项:
Menubar ? Editor ? Code Folding ? "Here is list of code folding options"
菜单栏 ?编辑?代码折叠 ? “这是代码折叠选项列表”
Here is ref snapshot:
这是参考快照:
Same options from Xcode Short-cut list:
来自 Xcode Short-cut list 的相同选项:
Menubar ? Xcode ? Preferences ? Key Bindings ? "Here is list of code folding short-keys"
菜单栏 ?代码?喜好 ?键绑定?“这是代码折叠快捷键列表”
回答by Ashish Chauhan
X-Code 7 onwards
X-Code 7 以后
To collapse all method : Shift+ Option+ Command+ Left arrow
要折叠所有的方法:Shift+ Option+ Command+Left arrow
To expand all method : Shift+ Option+ Command+ Right arrow
要展开所有方法:Shift+ Option+ Command+Right arrow
回答by Ashish Chauhan
Looks like Ctrl-Command-Updoes it (or on the menu: Editor-CodeFolding-FoldMethods/Functions).
看起来像Ctrl- Command-Up是吗(或在菜单上:Editor-CodeFolding-FoldMethods/Functions)。
Ctrl-Command-Downor Ctrl-Uto reverse.
Ctrl- Command-Down或Ctrl-U反转。