如何在XCode中快速删除/*和*/
在 XCode 中,有一些有用的函数用 /* 和相应的 */ 注释掉。有没有快捷方式可以快速删除这些?可以使用 AppleScript 创建快捷方式,还是有更好的方法?
In XCode there are some useful functions commented out with /* and a corresponding */. Is there a shortcut that will quickly remove these? Can a shortcut be made using AppleScript, or is there a better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 Command + / 注释/取消注释任何选定的代码块。
再次按下组合键以切换从已注释的代码块中删除注释
在 Xcode 4.2 中,我必须按 Command + Shift+/
You can comment/uncomment any selected code block with Command + /.
Press key combo again to toggle remove the comments from an already commented code block
In Xcode 4.2 I have to press Command + Shift+/
有一种更好的方法来注释和取消注释代码:Cmd + /。它将
//
放在每一行的前面,或者删除位于行前面的//
。这有很多优点。在 Xcode 中更容易做到。它正确筑巢。即使在 IDE 外部(例如在差异和代码审查工具中)读取代码,它也可以非常清楚地显示注释掉的代码的位置。当刚刚提交大量代码时,它使得差异变得更加明显(删除两行使其看起来像一个小变化,但您可能刚刚注入了数百行当前代码库中未经测试的代码) )。如果您正在寻找快捷方式,那么切换到前导
//
几乎肯定是更好的解决方案。There's a better way to comment and uncomment code: Cmd + /. It puts
//
in front of every line, or removes//
if it's at the front of the line. This has many advantages. It's easier to do in Xcode. It nests correctly. It makes it very clear where commented out code is, even when read outside of an IDE (such as in diffs and code-review tools). It makes it much more obvious in diffs when a huge amount of code has just been committed (removing two lines makes it look like a little change, but you may have just injected hundreds of lines of untested-in-the-current-codebase code).If you're in a situation where you're hunting for a shortcut, then switching to leading
//
is almost certainly a better solution.