tags:

views:

221

answers:

3

Hi everybody!

Is there a way to comment various lines at the same time in Xcode IDE? Selecting which lines to comment, then clicking somewhere et voilá.. the /* ... */ characters wrapping the code.

Thank you.

+2  A: 

There is such a function in the menu. Try: Edit->Insert Text Macro->C->Comment Section. It will create a (multi-line) comment around the currently selected text.

However, using the menu is probably often slower than manually inserting the comments. But, you can also bind a key to the menu item via the preferences key binding settings.

dmeister
Edit->Insert Text Macro->C->Comment Section
weichsel
Thank you dmeister. It's slower, yes. And also leaves uncomment feature out. Thank you for you readiness.
BigJoke
weichsel: you are right
dmeister
+6  A: 

Command + /

This inserts // in front of every selected line.

Georg
+2  A: 

Using /* */ is problematic because it does not nest. So what should it do if you select a section of code that contains a /* */ comment somewhere inside it?

newacct
Lines not commented turn into "active". You're right, that's a drawback.
BigJoke