xcode 有没有办法在已经评论过的部分上使用块评论?

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

Is there a way to use a block comment on a section that's already commented?

objective-cxcodecomments

提问by RanLearns

I know you can comment out a whole section of code like so:

我知道你可以像这样注释掉一整段代码:

/*
line of code
line of code
line of code
*/

But if you already have a /* ... */ section in the code that you are trying to comment, then the */ end of a comment block will close the "greater" comment block I am trying to create.

但是,如果您尝试注释的代码中已经有 /* ... */ 部分,那么注释块的 */ 结尾将关闭我正在尝试创建的“更大”注释块。

Example:

例子:

/* wanting to comment this big section out
line of code
line of code
line of code
line of code
line of code
line of code
/* this section was already commented out before
line of code
line of code
line of code
*/ this section was already commented out before
line of code
line of code
line of code
line of code
line of code
*/ this last part doesn't get commented out, because the comment stops at previous */

Obviously this isn't a huge big deal, it is not stopping me from getting an app to work properly, but I'm just wondering if there might be some way of commenting out a larger section of code, even if there are already comment blocks in that code.

显然这不是什么大问题,它并没有阻止我让应用程序正常工作,但我只是想知道是否有某种方法可以注释掉更大的代码部分,即使已经有注释该代码中的块。

回答by Gabriel

Highlight the code you want commented out and press "Command" + "/"

突出显示要注释掉的代码,然后按“Command”+“/”

回答by Bijoy Thangaraj

To avoid such a situation, always use //for commenting and use Xcode shortcut to comment a block of code.

为避免这种情况,请始终使用//注释并使用 Xcode 快捷方式对代码块进行注释。

The shortcut is cmd + /

捷径是 cmd + /

回答by joerick

I'd frown if I saw it in code, but you can do

如果我在代码中看到它,我会皱眉,但你可以

#if 0

...code...

#endif