Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Inserting an unmatched opening brace while having the "Automatically insert closing '}'" feature enabled.
Q: I have Xcode's "Automatically insert closing '}'" feature enabled, but sometimes I want to insert an unmatched opening brace. How can I do this?
A: Xcode supports arbitrary shell scripting that you can use to insert text into the editor view. In this case, you can create a new shell script that echoes the opening brace, replacing the current selection, and then create a key binding for that script.
To create a new shell script, start by opening the User Scripts window.

Then add a new shell script using the "+" button in the bottom left corner.

Initially the new script will not have a name or key binding, and the script contents will be as shown in Figure 3


Give the script a name and bind it to a key combination of your choice, such as "Command-Control-[". Then complete the shell script and set the Input, Output, and other options as shown in Figure 4


After you close the User Scripts window you can use the new key binding to insert an opening { that won't be matched by a closing brace.
Document Revision History
Date | Notes |
---|---|
2009-10-27 | New document that describes an Xcode shell script that inserts unmatched opening braces with the "Automatically insert closing '}'" feature enabled. |
Copyright © 2009 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2009-10-27