How to comment blocks of code which include commented lines already

I understand I can press "<Command> + /" to block comment sections of code. However, I want comment out 100 lines of code which consist of code statements and existing comments. Is there a way to block comment these 100 lines (and unblock them eventually) while preserving the existing comments as "comments"


In addition, I prefer not to use the /* */ comments as I like that each line itself is commented out.



For an easy example of what I would like to do:


1 // this is a comment

2 // this is a comment

3 for i in 1...4 {

4 print("\(i)"

5 }


I would like to block comment out the 5 lines to result in the following

(Please notice how lines 1 and 2 now have double comments)


1 // // this is a comment

2 // // this is a comment

3 // for i in 1...4 {

4 // print("\(i)"

5 // }


I would then like to unblock the 5 lines to result in the following

(Please notice how lines 1 and 2 are now back to the original comments)


1 // this is a comment

2 // this is a comment

3 for i in 1...4 {

4 print("\(i)"

5 }

Answered by Claude31 in 384460022

What you describe is what I get, on XCode11 as in earlier XCode.


What is your problem ? The double comment ?

But they are needed if you want to be able to uncomment later.


So I probably miss your point.

Accepted Answer

What you describe is what I get, on XCode11 as in earlier XCode.


What is your problem ? The double comment ?

But they are needed if you want to be able to uncomment later.


So I probably miss your point.

Claude31,


I jus ttested this again based on your comment and now it seems to work as I am requesting . Weird.


Earlier, I guess in some configuratino, the existing comment would be removed instead of a different set of comments "//" being applied.

Geex :>P Thanks for reply

How to comment blocks of code which include commented lines already
 
 
Q