Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Xcode have code autoformat feature?

Tags:

xcode

iphone

Is any way to autoformat a source code in the Xcode IDE?

like image 480
sashaeve Avatar asked Feb 11 '10 09:02

sashaeve


People also ask

Does Xcode have Formatter?

In the Xcode menu click [Editor] -> [Swimat] -> [Format] then the current active file will reformat. You can also create a hot-key in [Xcode] -> [Preferences..]

How do I AutoFormat in Visual Studio?

In the default configuration for Visual Studio Code, the command can be run using the shortcut Alt+Shift+F. To format a range, in an already opened project, open the document that you want to modify, select the specific range to format, right-click, and select Format Selection.

What is automatic format?

The AutoFormat As You Type tab provides options for formatting that occurs automatically based on what you type. Using this feature can minimize the need to apply changes from the Ribbon. AutoFormat As You Type provides three categories of options: Replace as you type, Apply as you type, and Automatically as you type.


2 Answers

There isn't really an autoformat option in Xcode.

There is an option ^I (Control-I) to re-indent the code, which will re-align the code according to the tab width set in your preferences, but that's about as far as it goes.

You might have better luck with a text editor like TextMate? I don't know for certain, but I know it supports Objective-C and has some macros, there may be a reformat option?

like image 167
Jasarien Avatar answered Sep 19 '22 12:09

Jasarien


Yes Xcode 4 has an autoformat feature.

Try following:

  1. Select text. CMD+A.
  2. Press CTRL+I .

Please also see here: Fix code indentation in Xcode

like image 27
Artem Kalachev Avatar answered Sep 20 '22 12:09

Artem Kalachev