开发者

How to delete /* and */ quickly in XCode

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?


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+/


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜