Search code examples
objective-cxcodekeyboard-shortcuts

How to escape from the bracket when writing Objective-C with Xcode?


I find writing Objective-C with Xcode sometimes could be painful when trying to escape from the bracket,

like I have to use the mouse or the direction key Right to continue after entering [UIView alloc].

Is there another way? Tab is not working :(

enter image description here


Solution

  • I assume Xcode is inserting the close bracket (]) for you, after your cursor. That happens because you have “Enable type-over completions” turned on in Xcode's preferences:

    preferences

    One way to handle this is by typing a close bracket when your cursor is at the close bracket. Because “Enable type-over completions” is turned on, Xcode will not insert another close bracket. It will just move the cursor past the existing close bracket. Try it! When you want to “escape from the bracket”, just type the bracket.

    Another way to handle this is by turning off the “Enable type-over completions” setting. If you turn it off, Xcode will not insert the close bracket for you, so you'll have to type the close bracket, but you won't have to “escape from the bracket” because there's no bracket to escape from.