Xcode comment uncomment issue

I am new to Xcode and found something disappointing. I select a few lines of code and comment on them. eg,

// NSString* u = __txtUsername.text; // NSString* p = __txtPassword.text; 

then I can postpone the code again, and the commented code will look below

  // NSString* u = __txtUsername.text; // NSString* p = __txtPassword.text; 

now if i try to uncomment the commented code, Xcode produces something like below

 // // NSString* u = __txtUsername.text; // // NSString* p = __txtPassword.text; 

in fact, instead of deleting // it adds more // at the beginning and removing // from the commented-out reflected code is really frustrating.

Is there any solution for this or did I do something funny?

+6
source share
5 answers

You are right, Xcode is stupid. If you get into this situation, continue to delete cmd- [to bring the text to the very beginning of the line, then uncomment it and it should work. Why is Xcode not just removing the first instance // from a string outside of me.

+11
source

Editor-> Structure-> Uncomment Selection

the option will not be displayed if the lines WITHOUT COMMENT are included in the selection

comments must appear in FIRST POSITION to be considered as such

+4
source

Just leave // all the way to the left, or the uncomment function really won't work.

If you need a multi-line comment, it is best to use this syntax:

 /* NSString* u = __txtUsername.text; NSString* p = __txtPassword.text; */ 

Then you need to remove /* and */ to uncomment the code block.

+1
source

If I need to comment on the non-trivial amount of code that I use:

 #if 0 code code code #endif // 0 

If this is a trivial amount of code, I do it manually. This is hardly manual labor compared to some works, so I am not against it.

I have never used the (un) comment-out command on any IDE.

+1
source

As long as you ONLY select the exact lines that are commented out, the uncomment function should work fine. If you select the commented code outside the uncommented code, then it refers to it as if you were "adding" to the already commented code. Which, since you know repeated indentation and comment out already commented code, if that makes sense. There shouldn't be a need to mess around indented ... Xcode should put everything right in the right place.

I like the concept of "/ * ... * /" from woz. I would like it to be more if there was a key combination that would make this method a little faster. Quick highlighting anywhere on the line, and pressing the "cmd /" key seems a little less accurate and fast for me.

Not sure if this was fixed on Xcode after this post, but thought I would comment on it.

Good luck everyone.

+1
source

All Articles