如何更改Xcode 4.5中的默认代码缩进?

时间:2012-12-29 03:30:29

标签: xcode4 indentation

创建新视图控制器时,其默认代码缩进样式如

- (void)viewDidLoad
{
    [super viewDidLoad];
  // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

我可以更改任何设置,以便默认代码缩进如下所示

- (void)viewDidLoad
{
  [super viewDidLoad];
  // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
  [super didReceiveMemoryWarning];
  // Dispose of any resources that can be recreated.
}

1 个答案:

答案 0 :(得分:23)

选择Xcode>首选项...从菜单栏(默认快捷键:命令 - 逗号)。然后单击“文本编辑”部分。然后选择“缩进”选项卡。将“缩进宽度”设置为2。

Xcode preferences

您可以通过在Project Navigator中选择项目,然后在File Inspector的“Text Settings”部分设置“Indent”值来更改一个项目的缩进宽度:

enter image description here

您可以通过选择代码并选择编辑器&gt;让Xcode使用新的缩进宽度重新格式化现有代码。 <结构>从菜单栏重新缩进(默认快捷键:control-i)。