NEW BOOK! SwiftUI Fundamentals: The essential guide to SwiftUI core concepts and APIs. Learn more ...NEW BOOK! SwiftUI Fundamentals:Master SwiftUI core concepts and APIs. Learn more...
Quick Tip Icon
Quick Tip

Format long parameter lists into separate lines in Xcode

When working with functions or initializers that take many parameters, especially when some values are closures or long arrays, the code can become difficult to scan and maintain. Xcode includes a useful keyboard shortcut for improving the readability of these calls.

To reformat them quickly, place the cursor inside the parentheses and press Control (⌃) + M. Xcode will automatically place each parameter on its own line.

If the entire expression is selected before using the shortcut, Xcode will also format the values, making closures and collections easier to read at a glance.

LinearGradient initializer with multiple parameters being reformatted onto separate lines using the Control-M shortcut