XCode: Function argument indentation
Asked Answered
A

2

22

I was unable to find any solution of my specific issue. I'm using Xcode 3.2. I'd like to indent the next line of function argument just one step in from the previous line:

somevariable = pow(
    a,
    b);

However, Xcode's syntax-aware indenting insists on converting the above into:

somevariable = pow(
                   a,
                   b);

Where the arguments are aligned with opening parenthesis of the function.

How can I make indenting be configured to match my preference?

Audy answered 17/5, 2010 at 18:28 Comment(7)
+1 good question. This is one of the more annoying things about XCode.Nephritis
Did you ever solve this?Vaucluse
I still haven't found a solution for this. And I am using Xcode 8.3. Any idea?Monas
Ok, this is a 10 year old issue, has anyone found any solutions to this?Berny
Still no apparent solution in 2022...Juvenal
And now in 2023...Remission
And in 2024, after at least 5 years of annoyance on my part... I've just decided to give up and resorted to turning off as much auto-formatting by Xcode as I can and just doing it all by hand. Luckily Xcode isn't my daily driver.Estrin
K
2

XCode (at least the version I have, 3.1.3) has a preferences pane called "indentation" that lets you click on/off a checkmark next to several characters such as semicolon, return,etc.

If you turn OFF the checkmark for return and semicolon, you can control the most important parts of your own indenting.

For instance, I declare my variables at the head of the function, and I like them flush; whereas XCode as first installed insisted on bringing them to the same level as the code.

I turned off the semicolon, and presto, it'll leave them there. Most of the time. It still screws them up during copy/pasta actions, but mostly it behaves. :)

Krute answered 15/3, 2011 at 22:49 Comment(0)
C
0

One solution could be to put the parentheses on the new line too. You will have something like this:

auto somevariable = pow
  (a,
   b);

Not the most elegant solution but the most effective if you want an automatically indentation from Xcode and if you are under a number of line constraint.

Callihan answered 8/10, 2018 at 12:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.