Xcode 9 展开/折叠大括号/方括号 {} 侧栏缺失

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44401963/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:00:55  来源:igfitidea点击:

Xcode 9 expand/collapse braces/brackets {} side bar missing

iosxcodexcode9code-foldingxcode10

提问by Yakiv Kovalsky

Can't find one under

在下面找不到

Xcode ? Preferences/Text Editing ? "Code Folding Ribbon" box.

代码?首选项/文本编辑?“代码折叠功能区”框。

回答by Krunal

Updates in Xcode 10:

Xcode 10 中的更新:

Xcode 10 has increased support for code folding, including:

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

  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
  1. 显示编辑器中所有多行可折叠代码块的新代码折叠功能区
  2. 编辑器中折叠代码的新样式,允许您编辑带有折叠代码的行
  3. 支持折叠花括号中的任何代码块
  4. 支持从折叠功能区、结构化选择或从

Menubar ? Editor ? Code Folding ? Fold menu item

菜单栏 ?编辑?代码折叠 ? 折叠菜单项

enter image description here

在此处输入图片说明

Look at this snapshot:

看看这个快照:

enter image description here

在此处输入图片说明



Xcode 9

Xcode 9

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 中根据 beta 版本说明:在 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 Foldoption.
  3. Select Foldfrom 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.
  1. 按住?键盘上的(命令)按钮并将鼠标光标移动/悬停在任何(开始或结束)大括号上。它会自动突出显示,阻止区域。
  2. 保持(按住)?(命令)按钮处于按下状态,然后单击突出显示的区域。它将启用带有Fold选项的快速菜单弹出窗口。
  3. Fold从菜单列表中选择。它将折叠您的代码并显示 3 个点,折叠/覆盖整个块。
  4. 现在,再次展开您的代码块,释放?(命令)按钮并单击折叠块的 3 个点。

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


Code folding options from Xcode Menu:


Xcode 菜单中的代码折叠选项

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:

来自 Xcode Short-cut list 的相同选项

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

菜单栏 ?代码?喜好 ?键绑定?“这是代码折叠快捷键列表”

enter image description here

在此处输入图片说明

回答by Jerry Krinock

Concurring with comment by @strangetimes, I submitted to Apple Bug Reporterthe following, in the new SUGGESTIONformat. Please feel free to pile on to Apple with your own:

同意@strangetimes 的评论,我以新的SUGGESTION格式向Apple Bug Reporter提交了以下内容。请随意使用您自己的 Apple 产品:

35237858 : Code Folding in Xcode 9.1 Only does Entire Functions/Methods

35237858:Xcode 9.1 中的代码折叠仅适用于整个函数/方法

UPDATE, A YEAR LATER…

更新,一年后……

This is fixed in Xcode 10. Code folding is back. Thanks to all those who piled on to the bug report or whatever.

这在 Xcode 10 中已修复。代码折叠又回来了。感谢所有那些堆积在错误报告或其他任何东西上的人。

The new, improved code folding in Xcode 9 or 9.1 seems to only work on an entire function or method. (I'm working in Objective-C today.) This is not very useful. You know, functions or methods are only one curly bracket deep. It is easy to eyeball them. Where I needcode folding is for long control flow blocks – if, else, switch, do, while, or just loose blocks. Please bring it back so I can use code folding as it worked in Xcode 8.

Xcode 9 或 9.1 中新的、改进的代码折叠似乎只适用于整个函数或方法。(我今天在 Objective-C 中工作。)这不是很有用。要知道,函数或方法只有一个大括号深。很容易注意到他们。我需要代码折叠的地方是长控制流块——if、else、switch、do、while 或只是松散的块。请把它带回来,这样我就可以像在 Xcode 8 中一样使用代码折叠。

The ribbon thing, although I thought it was good, others didn't – I can live without it. But code folding needs to work on all curly-bracket code blocksplease.

丝带的东西,虽然我认为它很好,但其他人不认为——我可以没有它。但是代码折叠需要适用于所有花括号代码块

回答by stone

I have the same question and I found this at forums.developer.apple.com

我有同样的问题,我在 forums.developer.apple.com 上找到了这个

...isn't implemented in the new editor yet. @https://forums.developer.apple.com/thread/78912

...尚未在新编辑器中实现。@ https://forums.developer.apple.com/thread/78912

回答by Sten

This doesn't do folding, but it might help you to navigate in the code:

这不会折叠,但它可能会帮助您在代码中导航:

If you want to find out which brackets that go together you can click just behind the start or end bracket, you will then get a one second highlight of both. Or you can double click or either bracket and get permanent highlight of everything between the brackets.

如果您想找出哪些括号放在一起,您可以在开始或结束括号后面单击,然后您将获得两个突出显示的一秒钟。或者您可以双击或任一括号并永久突出括号之间的所有内容。

回答by Aladin

It is fixed now in Xcode_9_beta_5

现在已在Xcode_9_beta_5修复

回答by Jonathan Cabrera

Xcode 9

Xcode 9

As it has already been commented, the code folding in Xcode 9 only works on entire functions. The closest I got to a way to figure out where does a curly brace closes (especially for long foror ifblocks), is by double tapping in the curly brace. This will highlight that block of code until the curly brace closes.

正如已经评论过的那样,Xcode 9 中的代码折叠仅适用于整个函数。我最接近找出花括号关闭位置的方法(特别是对于长括号forif块),是双击花括号。这将突出显示该代码块,直到花括号关闭。

Of course, this will work much better in Xcode 10 with the new code folding ribbon.

当然,这在 Xcode 10 中使用新的代码折叠功能区会更好。