XCode 3.2: Changing the default “Code Sense” indentation and whitespaces

后端 未结 2 835
有刺的猬
有刺的猬 2021-01-31 00:57

I\'m working with XCode 3.2 (on \"Snow Leopard\") which (still) has this nice \"Text Macro\" auto-completion feature (eg. if you type if it will expand to if

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-31 01:07

    The only **.xctxtmacro* files on my system were within the XCode.app bundle. After having a quick look a the definitions, I found a completely different way of adapting the formatting of all predefined macros:

    You can simply set the XCCodeSenseFormattingOptions user defaults to modify the default newlines and other whitespaces within all macros!

    For example the macro "if-else" looks like this by default:

    if (<#condition#>) {
        <#statements#>
    } else {
        <#statements#>
    }
    

    After executing the command

    defaults write com.apple.Xcode XCCodeSenseFormattingOptions
    -dict PreExpressionsSpacing "" BlockSeparator "\n" PostBlockSeparator "\n"
    

    it looks like this (which I prefer):

    if(<#condition#>)
    {
        <#statements#>
    }
    else
    {
        <#statements#>
    }
    

提交回复
热议问题