2012-12-29 73 views
5

當我創建了一個新的視圖控制器,它的默認代碼的縮進風格看起來像如何更改Xcode 4.5中的默認代碼縮進?

- (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. 
} 

回答

11

選擇的Xcode>首選項...從菜單欄(默認快捷鍵:命令逗號)。然後點擊「文本編輯」部分。然後選擇「縮進」選項卡。在「縮進寬度」設定爲2

Xcode preferences

您可以通過在Project Navigator中選擇項目,然後在「文本設置」設置「縮進」值更改壓痕寬度只有一個項目文件檢查器的部分:

enter image description here

你可以問Xcode中選擇的代碼,然後選擇編輯器>結構>重新縮進從菜單欄(默認快捷鍵來重新格式化新壓痕寬度現有代碼:控制-一世)。

+2

我已經嘗試過,但它不起作用。當我創建一個新項目或一個新的.m文件時,默認縮進保持不變。 – Daniel