I'm writing ANSI-compatible C code, and hence I can't use the line (//
) comment. I'm using Xcode. In Sublime Text and Eclipse, and I think most other IDEs, there are separate keyboard shortcuts for line comments and block comments (/**/
). However, I don't see that in Xcode - in fact, I don't even see a menu option to add a block comment. Is it simply not supported in Xcode? That would certainly seem to be a lame decision if so.
相关问题
- Xcode debugger displays incorrect values for varia
- Image loads in simulator but not device?
- importing files from other directories in xcode
- XCode Server: Opening import file for module '
- create tableview inside tableviewcell using swift
相关文章
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- Popover segue to static cell UITableView causes co
- “Storyboard.storyboard” could not be opened
- didBeginContact:(SKPhysicsContact *)contact not in
-
The file “
.app” couldn’t be opened becaus - How do I set compatible devices to only ARKit comp
UPDATE: Xcode 8 Update
Now with xcode 8 you can do:
⌥ + ⌘ + /
Note: Below method will not work in xcode version => 8
Very simple steps to add Block Comment functionality to any editor of mac OS X
awk 'BEGIN{print "/*"}{print $0}END{print "*/"}'
Block Comment
Open System Preference > Keyboard > Shortcuts, add new shortcut by clicking
+
and right the same name i.e.Block Comment
as you given to applescript in the 4th step. Add your Keyboard Shortcut and click Add button.Now you should be able to use block comment in Xcode or any other editor, select some text, use your shortcut key to block comment any line of code or right click, the context menu, and the name you gave to this script should show near the bottom.
If you're looking a way to convert autogenerated comment from
Add Documentation
action (available under cmd-shift-/) you might find it useful too:Rest the same as in @Charles Robertson answer:
I modified the code of Nikola Milicevic a little bit so it also remove comment block if code is already commented:
Hope this will help someone.
Now with xCode 8 you can do:
⌥ + ⌘ + /
to auto-generate a doc comment.
Source: https://twitter.com/felix_schwarz/status/774166330161233920
Try command + /. It works for me.
So, you just highlight the block of code you want to comment out and press those two keys.
Cmd + Shift + 7 will comment the selected lines.