When I created a new view controller, its default code indentation style looks like
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
Can I change any settings so the default code indentation looks like below
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
In Xcode 10, if you press Command and hover over the structure it will show what is desired.
Xcode tip #21: If you've copied code from elsewhere, such as Hacking with Swift or Stack Overflow, there's a good chance you'll paste in something with incorrect indentation. Xcode can fix this with one shortcut: select the code you want to fix, then press Ctrl+I to reindent it.
You need to open Xcode's Navigation preferences, and for “Navigation Style” select “Open In Place”. The new “inner tab bar” will disappear, and the previous tab behavior (and shortcuts!) will be restored.
Choose Xcode > Preferences… from the menu bar (default shortcut: command-comma). Then click the “Text Editing” section. Then choose the “Indentation” tab. Set the “Indent width” to 2.
You can change the indentation width for just one project by selecting the project in the Project Navigator, then setting the “Indent“ value in the “Text Settings” section of the File Inspector:
You can ask Xcode to reformat existing code with the new indentation width by selecting the code and choosing Editor > Structure > Re-Indent from the menu bar (default shortcut: control-i).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With