Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncommenting code in xcode just adds more comments

Tags:

xcode

When commenting out a piece of code in xcode

//code

If you click comment again it adds more comments

////code

does anyone know how to prevent this?

like image 566
TheLearner Avatar asked Jun 16 '10 13:06

TheLearner


People also ask

How do I comment multiple lines of code in Xcode?

By selecting a few lines of code (pressing ⇧+↑ or ⇧+↓), you can comment a bunch of lines in a single shot with the ⌘ + / shortcut. If the lines are already comments, the same shortcut will uncomment them.

How do you comment multiple lines of code?

The leading characters // are added to the beginning of each line when commenting one or more lines of code. You can also block comment multiple lines of code using the characters /* */ .


2 Answers

It looks like a bug to me .... if you do command + ] it gets rid of the tabs.. The tabs are the ones causing the issue. Xcode sees the tabs and adds more comment lines. so do command +] twice or until all the tabs are gone. and then you can remove the comments using the command+/ (comment selection command)

like image 129
j2emanue Avatar answered Oct 20 '22 00:10

j2emanue


When you "click comment again" you have to have the // selected (and optionally the rest of the line).

Usually when you comment the first time Xcode will select the text such that pressing the comment shortcut again will uncomment.

Is nothing selected after you comment the first time?

like image 33
Jon-Eric Avatar answered Oct 19 '22 23:10

Jon-Eric