Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change the way Xcode indents comment lines?

      cout<<"hello"<<endl;        //line1
//    cout<<"hello"<<endl;        //line2
      //    cout<<"hello"<<endl;  //line3
      //cout<<"hello"<<endl;      //line4
      //                                        cout<<"hello"<<endl; //line 5            

I write the line1.

Then I comment line1 using command+/, it becomes line2.

But when I Re-Indent line2 using control+I (Or pasting the line to another place in Xcode), It becomes line3.

I think the blank after "//" is very ugly in line3. Sometimes it will be very long such as line 5.

So I want to know is there a shortcut to comment the line1 to line4, so it will not be inflounced by Re-Indent or Paste?


Update:

Is it possible to change the way Xcode indents comment blocks?

I try this command from this answer in command line. And reboot Xcode and system.

But It still get line3.

defaults write com.apple.Xcode XCCodeSenseFormattingOptions -dict PreExpressionsSpacing  "" PreCommaSpacing " "

I want to change the way xcode indents comment "line", not "blocks" So, this question is different from mine. And it can not solve my problem.

like image 441
Alice Avatar asked Oct 28 '25 05:10

Alice


1 Answers

There is a Xcode extension for commenting just before indented code.

It makes like

    cout<<"hello"<<endl;        //line1
    // cout<<"hello"<<endl;     //line2`

So a indent of commented block is not changed even after re-indent

like image 94
moosoy_ Avatar answered Oct 29 '25 20:10

moosoy_



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!