如何折叠Xcode中的所有方法?

发布于 2024-09-01 17:14:39 字数 51 浏览 4 评论 0原文

如何在 Xcode 中折叠类中的所有方法?

一处崩溃已经不再是一种选择。

How to collapse all methods in a class in Xcode?

Collapsing one by one is not an option anymore.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

念三年u 2024-09-08 17:14:39

从 Xcode 4 开始,它似乎发生了变化。

command-alt-shift-左箭头就可以了...

折叠/展开当前方法或if 结构使用:

折叠:command-alt-左箭头

展开:command -alt-右箭头

As of Xcode 4 it seems to have changed.

command-alt-shift-left arrow will do the trick...

To fold/unfold current methods or if structures use:

Fold: command-alt-left arrow

Unfold: command-alt-right arrow

呆萌少年 2024-09-08 17:14:39

Xcode 10 中的更新

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

  1. 新的代码折叠功能区,显示编辑器中所有多行可折叠代码块 编辑
  2. 器中折叠代码的新样式,允许您编辑包含折叠代码的行
  3. 支持折叠所包含的任何代码块在大括号中
  4. 支持从折叠功能区、结构化选择或从

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

在此处输入图像描述

看看这个快照:

在此处输入图像描述


代码折叠在 Xcode 9 beta 1 中被禁用,根据 beta 发行说明,代码折叠现在在 Xcode 9 Beta5 中可用:已在 Xcode 9 beta 5 – IDE 中解决 操作

方法如下:

  1. 按住 ⌘键盘中的 (命令)按钮并将鼠标光标移动/悬停在任何(开始或结束)大括号上。它会自动突出显示、遮挡区域。
  2. 保持(按住)(命令)按钮处于按下状态,然后单击突出显示的区域。它将启用带有 Fold 选项的快速菜单弹出窗口。
  3. 从菜单列表中选择折叠。它将折叠您的代码并显示 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 + right

**Code folding options from Xcode Menu**:
> Menubar ▶ Editor ▶ Code Folding ▶ "Here is list of code folding options"

这是参考快照:

< img src="https://i.sstatic.net/78DMm.png" alt="在此处输入图像描述">

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

菜单栏 ▶ Xcode ▶ 首选项 ▶ 键绑定 ▶ “这是代码折叠快捷键列表”

在此处输入图像描述

Updates in Xcode 10

Xcode 10 has increased support for code folding, including:

  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

enter image description here

Look at this snapshot:

enter image description here


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

Here is how:

  1. Press and hold (command) button in keyboard and move/hover mouse cursor on any (start or end) braces. It will automatically highlight, block area.
  2. Keep (hold) (command) button in pressed condition and click on highlighted area. It will enable quick menu popover window with Fold option.
  3. Select Fold from menu list. It will fold your code and shows 3 dots, folding/covering entire block.
  4. Now, to again unfold your code block, release (command) button and click on 3 dots folding a block.

For easy understanding, look at this snapshot:

enter image description here

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 + right

**Code folding options from Xcode Menu**:
> Menubar ▶ Editor ▶ Code Folding ▶ "Here is list of code folding options"

Here is ref snapshot:

enter image description here

Same options from Xcode Short-cut list:

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

enter image description here

瑕疵 2024-09-08 17:14:39

X-Code 7 及以上

要折叠所有方法: Shift + Option + Command + 向左箭头

展开所有方法:Shift + 选项 + 命令 + 向右箭头

X-Code 7 onwards

To collapse all method : Shift + Option + Command + Left arrow

To expand all method : Shift + Option + Command + Right arrow

泛泛之交 2024-09-08 17:14:39

我喜欢克鲁纳尔的回答(上面)中的这张表:https://stackoverflow.com/a/46020397/1554947

Fold                          ⌥ ⌘ ←      option + command + left arrow
Unfold                        ⌥ ⌘ →      option + command + right arrow
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 + right

I like this table from Krunal's answer (above) : https://stackoverflow.com/a/46020397/1554947

Fold                          ⌥ ⌘ ←      option + command + left arrow
Unfold                        ⌥ ⌘ →      option + command + right arrow
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 + right
厌倦 2024-09-08 17:14:39

看起来 Ctrl-Command-Up 可以做到这一点(或在菜单上:Editor-CodeFolding-FoldMethods/Functions)。

Ctrl-Command-向下Ctrl-U 反转。

Looks like Ctrl-Command-Up does it (or on the menu: Editor-CodeFolding-FoldMethods/Functions).

Ctrl-Command-Down or Ctrl-U to reverse.

淡淡绿茶香 2024-09-08 17:14:39
  1. 按 COMMAND + ,“命令逗号”

  2. 单击“文本编辑”选项卡

  3. 选中“代码折叠功能区”

就在行号右侧,您将看到一个新功能区,函数/方法旁边带有向上或向下箭头。按这些按钮将允许您展开或折叠功能/方法。

  1. Press COMMAND + , "command comma"

  2. Click "Text Editing" tab

  3. Check "Code Folding Ribbon"

Just to the right of line numbers you will see a new ribbon with up or down arrows next to functions / methods. Pressing these will allow you to expand or collapse functions / methods.

小伙你站住 2024-09-08 17:14:39

Shift + Option + Command + 向左箭头,对我不起作用。
如果使用“查找”并输入“[”,我发现了一个解决方法。
使用“Return”跳至数组。当您找到想要关闭的窗口时,请使用“Option + Command + 向左箭头”。
您可以非常快速地关闭大量数组,而无需单击

Shift + Option + Command + Left arrow, did not work for me.
A work around I have found if use "Find" and put in "[".
use "Return" to skip to arrays. When you come to one you want to close, use the "Option + Command + Left arrow".
you can very quickly close a lot of array without ever clicking

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文