如何在 Xcode 中打开括号匹配?

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

How can I turn on parenthesis matching in Xcode?

xcodetext-editor

提问by MrDatabase

Curly brace matching was pretty easy to turn on. How can I turn on parenthesis matching in Xcode?

花括号匹配很容易打开。如何在 Xcode 中打开括号匹配?

采纳答案by coneybeare

You must be running Xcode in Snow Leopard and install Xcode from the Snow Leopard disc that you got at WWDC. If you did not get a Snow Leopard disk, then you are out of luck unless you find one elsewhere.

您必须在 Snow Leopard 中运行 Xcode,并从您在 WWDC 获得的 Snow Leopard 光盘安装 Xcode。如果您没有得到 Snow Leopard 磁盘,那么除非您在别处找到它,否则您就不走运了。

The version of Xcode needed is 3.2 and the other components in the about page are:

所需的 Xcode 版本为 3.2,关于页面中的其他组件为:

Component versions

组件版本

  • Xcode IDE: 1600.0
  • Xcode Core: 1599.0
  • ToolSupport: 1591.0
  • Xcode IDE:1600.0
  • Xcode 核心:1599.0
  • 工具支持:1591.0

回答by MPaulo

Choose editor -> code folding -> focus

选择编辑器 -> 代码折叠 -> 焦点

回答by shazzing

on Xcode Version 6.1 (6A1052d), you just need to double click on one of the parenthesis and the entire code that the parenthesis is scoping out is highlighted.

在 Xcode 版本 6.1 (6A1052d) 上,您只需要双击其中一个括号,括号内的整个代码就会突出显示。

for example, if you have a code like the one below and you double click '{' or '}' bracket the entire code in their scope is highlighted :

例如,如果您有一个类似于下面的代码,并且您双击“{”或“}”括号,则会突出显示其范围内的整个代码:

if(condition == true) { //do something }

如果(条件 == 真) { //do something }

回答by Vyacheslav

Edit

编辑

In XCode 9 the only solution is to put mouse over parentheses while pressing command button. Only this works.

在 XCode 9 中,唯一的解决方案是在按下命令按钮的同时将鼠标放在括号上。只有这个有效。

Previous

以前的

To extend the other answers it is possible to roll in/out code inside brackets.

要扩展其他答案,可以在括号内滚入/滚出代码。

Choose Editor > Structure > Balance Delimiter

选择编辑器 > 结构 > 平衡分隔符

url

网址

Nevertheless, as already written earlier, the major feature is

然而,正如前面已经写过的,主要特点是

Editor > Code Folding > Focus Follows Selection

编辑器 > 代码折叠 > 焦点跟随选择

回答by Alok

Please have a look at below answer for Xcode 9.0 and above:

请查看以下 Xcode 9.0 及更高版本的答案:

Xcode highlights an opening delimiter (brace, bracket, parenthesis) when you move the cursor left-to-right over the matching closing delimiter. The highlight animation lasts about 1 second total, which is plenty in the case where you need a hint (and as you say the other delimiter is nearby).

当您将光标从左到右移动到匹配的结束定界符上时,Xcode 会突出显示一个开始定界符(大括号、方括号、圆括号)。高亮动画总共持续大约 1 秒,这在您需要提示的情况下已经足够了(正如您所说的另一个分隔符在附近)。

If you need a more persistent indication, you can double-click either the opening or the closing delimiter, and Xcode will select both delimiters and their contents. (You can also use this, for example, to get quickly to one delimiter from another, even if they're far apart — double-click the delimiter you can see, use the left or right arrow to get the other end of the selection.)

如果您需要更持久的指示,您可以双击开始或结束定界符,Xcode 将选择这两个定界符及其内容。(例如,您也可以使用此功能从另一个分隔符快速到达另一个分隔符,即使它们相距很远 - 双击您可以看到的分隔符,使用向左或向右箭头获取选择的另一端.)