XCode 4.3 左花括号独立成行

目的:希望将XCode默认代码中类似以下代码
if (<#condition#>) {
    <#statements#>
}
中的左花括号,替换成下面这种默认格式。
if (<#condition#>)
{
    <#statements#>
}

 

XCode4.3中,左花括号分为两种,一种是在文件模版中,比如*.h和*.m文件默认代码中的左花括号。

这种修改参见以下连接:

【转】xcode4自定义文件模板(Creating Custom Xcode 4 File Templates) 

 

另一种,就是if、switch这类代码块中,这类的模版文件路径如下:

/Applications/Xcode.app/Contents/PlugIns/IDECodeSnippetLibrary.ideplugin/Contents/Resources/SystemCodeSnippets.codesnippets 

 

以if代码块为例,在此文件中找到以下代码:

 1  < dict >
 2      < key >IDECodeSnippetVersion </ key >
 3      < integer >1 </ integer >
 4      < key >IDECodeSnippetCompletionPrefix </ key >
 5      < string >if </ string >
 6      < key >IDECodeSnippetContents </ key >
 7      < string >if ( &lt;#condition# &gt;) {
 8    &lt;#statements# &gt;
 9 } </ string >
10      < key >IDECodeSnippetIdentifier </ key >
11      < string >D70E6D11-0297-4BAB-88AA-86D5D5CBBC5D </ string >
12      < key >IDECodeSnippetLanguage </ key >
13      < string >Xcode.SourceCodeLanguage.C </ string >
14      < key >IDECodeSnippetSummary </ key >
15      < string >Used for executing code only when a certain condition is true. </ string >
16      < key >IDECodeSnippetTitle </ key >
17      < string >If Statement </ string >
18      < key >IDECodeSnippetCompletionScopes </ key >
19      < array >
20          < string >CodeBlock </ string >
21      </ array >
22  </ dict >

将第7行左花括号左边的空格改成回车即可,完成后如下。

 1  < dict >
 2      < key >IDECodeSnippetVersion </ key >
 3      < integer >1 </ integer >
 4      < key >IDECodeSnippetCompletionPrefix </ key >
 5      < string >if </ string >
 6      < key >IDECodeSnippetContents </ key >
 7      < string >if ( &lt;#condition# &gt;)
 8 {
 9    &lt;#statements# &gt;
10 } </ string >
11      < key >IDECodeSnippetIdentifier </ key >
12      < string >D70E6D11-0297-4BAB-88AA-86D5D5CBBC5D </ string >
13      < key >IDECodeSnippetLanguage </ key >
14      < string >Xcode.SourceCodeLanguage.C </ string >
15      < key >IDECodeSnippetSummary </ key >
16      < string >Used for executing code only when a certain condition is true. </ string >
17      < key >IDECodeSnippetTitle </ key >
18      < string >If Statement </ string >
19      < key >IDECodeSnippetCompletionScopes </ key >
20      < array >
21          < string >CodeBlock </ string >
22      </ array >
23  </ dict >

 

 

参考资料: http://stackoverflow.com/questions/5120343/xcode-4-with-opening-brace-on-new-line

转载于:https://www.cnblogs.com/yencain/articles/2503786.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值