在 xcode 中取消注释代码只会添加更多注释

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

Uncommenting code in xcode just adds more comments

xcode

提问by TheLearner

When commenting out a piece of code in xcode

在 xcode 中注释掉一段代码时

//code

//代码

If you click comment again it adds more comments

如果您再次单击评论它会添加更多评论

////code

////代码

does anyone know how to prevent this?

有谁知道如何防止这种情况?

采纳答案by Jon-Eric

When you "click comment again" you have to have the //selected (and optionally the rest of the line).

当您“再次单击评论”时,您必须//选择(以及可选的其余行)。

Usually when you comment the first time Xcode will select the text such that pressing the comment shortcut again will uncomment.

通常当你第一次评论时,Xcode 会选择文本,这样再次按下评论快捷方式将取消评论。

Is nothing selected after you comment the first time?

第一次评论后没有任何选择吗?

回答by j2emanue

It looks like a bug to me .... if you do command + ] it gets rid of the tabs.. The tabs are the ones causing the issue. Xcode sees the tabs and adds more comment lines. so do command +] twice or until all the tabs are gone. and then you can remove the comments using the command+/ (comment selection command)

对我来说这看起来像是一个错误....如果你执行 command + ] 它会摆脱标签..标签是导致问题的原因。Xcode 会看到选项卡并添加更多注释行。所以执行 command +] 两次或直到所有选项卡都消失了。然后您可以使用 command+/ (评论选择命令)删除评论