隐藏/取消隐藏 xcode 中的所有注释
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/914149/
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
hide/unhide all comments in xcode
提问by lajos
Is there a way to hide/unhide all comments in xcode source files?
有没有办法隐藏/取消隐藏 xcode 源文件中的所有注释?
This would be very helpful when working with code that has way too many comments added.
这在处理添加了太多注释的代码时非常有用。
回答by Derek Swingley
You can use fold/unfold to hide/show comments using ???↑ and ???↓. This is also accessible through View --> Code Folding --> Fold/Unfold Comment Blocks.
您可以使用折叠/展开来隐藏/显示评论,使用 ???↑ 和 ???↓。这也可以通过查看 --> 代码折叠 --> 折叠/展开注释块访问。
回答by evya
Try: Ctrl + Command + Shift + Left Or Ctrl + Command + Left
尝试:Ctrl + Command + Shift + Left 或 Ctrl + Command + Left
回答by Mish
Surrounding any code with
围绕任何代码
/*
....code here....
*/
makes that comment into a section that you can fold/unfold.
将该评论变成可以折叠/展开的部分。
This works even for blocks of code already commented out with // in long blocks.
这甚至适用于已经在长块中用 // 注释掉的代码块。
Hope this helps someone even though this question is 4 years old!
希望这对某人有所帮助,即使这个问题已经有 4 年的历史了!
回答by boulder_ruby
Expanding a bit on Mish's answer because XCode is very subtle with its UI
稍微扩展 Mish 的答案,因为 XCode 的 UI 非常微妙
As @Mish pointed out, surrounding any code with /* ... */
makes that code fold/unfold-able just like your { ... }
sections.
正如@Mish 指出的那样,围绕任何代码/* ... */
使该代码可以像您的{ ... }
部分一样折叠/展开。
I haven't had any luck with any of the keyboard shortcuts listed on this answer page yet, but if you hoverover the left hand side of the /*...*/
section you'll see the UI change in response to that like so:
我还没有使用此答案页面上列出的任何键盘快捷键,但是如果您将鼠标悬停在该/*...*/
部分的左侧,您将看到 UI 更改以响应如下所示:
that when clicked will collapse the comments. I for one intend on trying to do all comments with the /.../ format from now on.
单击时将折叠评论。我打算从现在开始尝试使用 / .../ 格式进行所有评论。
PS: Note that /*...*/
comments can be inline with code on either side and still be collapsable.
PS:请注意,/*...*/
注释可以与任一侧的代码内联,并且仍然可以折叠。
EDIT: I'm finding that collapsing comments inside of some {...}
brackets is not working because XCode is collapsing the entire {}
section instead...
编辑:我发现一些{...}
括号内的折叠注释不起作用,因为 XCode 正在折叠整个{}
部分......
回答by Fausto Checa
A very easy and practical way to hide all // comments is to change the comments' color to black (or other background editor color you are using, normally dark color) in Xcode preferences.
// 隐藏所有注释的一种非常简单实用的方法是在 Xcode 首选项中将注释的颜色更改为黑色(或您正在使用的其他背景编辑器颜色,通常为深色)。
When you want to see them again, just change color to primitive one, such as green
当您想再次看到它们时,只需将颜色更改为原始颜色,例如绿色
回答by Martian2049
I'm made a summary , it works for me. It's late but a good flow helps writing good code. for swift 3-4
only
我做了一个总结,它对我有用。为时已晚,但好的流程有助于编写好的代码。对于swift 3-4
只
In case where you want to write pseudo code first before actual code, you can write everything into a comment block
/* first, use http request in the callback, do a. b. c. */
then because you might re-write but the logics are mostly the same, so you might not want to remove the comments, that's fine, but make sure they don't block your view, so you define a short-cut that conveniently fold/unfold all the comment block into one line. (That's the best you can do.); Then when you fold them, it looks like this:
/*...
to Define shortcut, go to Xcode => Preference => Key Bindings =>
fold comment block
如果您想在实际代码之前先编写伪代码,您可以将所有内容写入注释块
/* first, use http request in the callback, do a. b. c. */
然后因为您可能会重新编写但逻辑大体相同,所以您可能不想删除注释,这很好,但请确保它们不会挡住您的视线,因此您定义了一个方便折叠的快捷方式/将所有注释块展开为一行。(这是你能做的最好的。);然后当你折叠它们时,它看起来像这样:
/*...
要定义快捷方式,请转到 Xcode => Preference => Key Bindings =>
fold comment block
In my case I use alt?ctrl{
, alt?ctrl}
在我的情况下,我使用 alt?ctrl{
,alt?ctrl}
then define it anyway you want, but be careful of conflicts.
然后随意定义它,但要小心冲突。
It really pays to have pseudo code comments folded
折叠伪代码注释确实值得