From the blog

Spicing Up Xcode

Six Flags and Google App Development

At the third Raizlabs Lightning Talks, I ate a Scotch bonnet pepper and presented 13 tips and tricks about Xcode. If you missed the talk, or wanted to know about one of the slides in more detail, here’s a video and a written version of everything I mentioned, plus a few extras.

Spicing Up Xcode was inspired by Hot Pepper Gaming, a spectacular YouTube channel that answers the age-old question of what would happen if a bunch of professional game reviewers ate hot peppers and then reviewed video games.

Mac Keyboard Symbols

First, a refresher on some of the more obscure keyboard symbols.

⌘ Command
⇧ Shift
⌥ Option
⌃ Control
↩ Return
← ↓ → ↑ Arrow Keys

Spicing Up Xcode – Keyboard Shortcuts

1. Control-Arrows to Jump by Camel Case

You can use ⌃→ and ⌃← to jump forward and backward by camel case substrings in any text in the editor. For example, if your insertion point is at the beginning of tableView and you want to jump to between table and View, press ⌃→ and the cursor will move right one camel case substring. This also works in combination with the standard OS X text navigation shortcuts. For example, press ⌃⇧→ to select the next camel case substring, or ⌃delete to delete the previous camel case substring.

Note that you may have to disable OS X’s default keyboard shortcuts for moving between Spaces, which use the same key combinations. You can do this under System PreferencesKeyboardShortcutsMission Control, and uncheck the boxes next to Move left a space and Move right a space.

Sadly, jumping by camel case is not supported in Xcode’s native text fields (such as the Search field), nor elsewhere in OS X. I’ve filed a radar.

2. Balance Delimiter

This Xcode command is located under EditorStructureBalance Delimiter. It selects the next outermost set of brackets, braces, or parentheses from the current selection. This is similar to the behavior where double-clicking a bracket, brace, or parenthesis will select its counterpart and everything in between. You can see both behaviors in this screen recording:

Screen recording showing selecting through matching braces and using the Balance Delimiter command.
Screen recording demonstrating the ability to select through matching braces, as well as the Balance Delimiter command.

You can set a keyboard shortcut for Balance Delimiter in Xcode Preferences Key Bindings. My shortcut of choice is ⌘⇧Space.


Xcode has dozens of commands and keyboard shortcuts to support many different kinds of navigation. You owe it to yourself to spend a while browsing through the View, Find, and Navigate menus to see what’s available. Try holding ⇧, ⌥, and ⇧⌥ to see what hidden commands are lurking in there!

It would take several blog posts to cover all of the navigation shortcuts, but here some of my favorites:

3. Reveal in Project Navigator: ⌘⇧J

Opens the left sidebar, shows the Project Navigator, and selects the file you are currently editing. Convenient for seeing where it is in the project, and what its siblings and related files are.

4. Show Documentation: ⌥ Click

Option-click any method to show a popup with the documentation for that method. If you’re using a trackpad, you can also three-finger tap on the method. The best part: this works with all your own /** documentation comments */  (like the ones you can create using VVDocumenter-Xcode).

Three-finger tap or Option-click on a method to show its documentation in a popover.
Three-finger tap or Option-click on a method to show its documentation in a popover.

5. Open Documentation: ⌥ Double Click

If you want to open the full documentation browser for a particular method, Option-double click it. This is particularly useful for some of the core Apple framework methods, such as -[UIView isOpaque], since their long Discussion sections don’t appear in the popover mentioned above.

6. Open in Other Editor: ⌘⌥,

When you are editing a file in the primary editor, this shortcut will open it in the assistant editor. When you are in the assistant editor, it will open the same file in the main editor. This is useful when combined with other shortcuts to open files in various editors. For example, if you are working on a file in the assistant editor, but you want to promote it to the main editor before you open a new file in the assistant editor, this shortcut makes it easy.

7. Jump to Definition in… ⌘⌥⌃ Click

Like the above command, this one is contextual: whichever editor you are in, it opens a file in the other. However, instead of opening the current file in the other editor, it opens the definition of the symbol you click.

8. Better Navigation Through Trackpad Settings

OS X trackpad gestures have come a long way since they were introduced. Originally, you swiped with three fingers to navigate: left to go forward, right to go back. Later, this was replaced by a two-finger continuous drag gesture in the opposite direction. This shortcut fits better with the “natural” scroll direction introduced in OS X Lion, but it can be annoying to have to sit through a swipe animation when you want to quickly jump between files.

Luckily, by twiddling a couple of trackpad settings, you can get the best of both worlds: the pretty, continuous two-finger transitions, and the instantaneous three-finger swipes. Note that they go in opposite directions from each other, but as long as you can keep that straight, you can use them interchangeably. To change these settings, go to System PreferencesTrackpadMore Gestures, and make the following changes:

  • Swipe between pages: Swipe with two or three fingers. Enables three-finger swipes.
  • Swipe between full-screen apps: Swipe left or right with four fingers. Frees up three-finger swipes from having to switch spaces, which you can now do with four fingers.
  • Bonus setting: change Mission Control and App Exposé each to use four fingers (or disable them if you don’t use them). This will allow you to swipe up or down in Xcode to switch between a class’s .h and .m files. The keyboard shortcut equivalents of these are ⌃⌘↑ and ⌃⌘↓. (Are going “up” and “down” the same? For normal .h/.m pairs, yes, but if you have .h, .m, and _Private.h, the shortcuts cycle through them forward and backward.)

9. Open Quickly ⌘⇧O

Anywhere in Xcode, type ⌘⇧O (as in oh, not zero) to bring up the Open Quickly dialog box. You can type the name of any file or symbol, and it will do a fuzzy match of everything in your project, plus all of Apple’s public headers. It searches file names, methods, functions, properties, and constants. The “fuzzy” part means that, while you have to get the letters in the right order, you can leave some out.

In the example below, the file I’m looking for is called INVEditCreditCardsButtonView.xib. I can’t remember the full name, but I know it had something to do with editing cards, and maybe it was a button, so I type “editcardbutton” into Open Quickly, and the first few results are pretty close to what I want:

Type a few letters to fuzzily match every file, symbol, and property in your project.
Type a few letters to fuzzily match every file, symbol, and property in your project.

But remember, I wanted the xib. I could press the down arrow key twice, or use the mouse to double click the third result, but there’s an easier way. Since the file extension is taken into account in this dialog box, I can just add an additional “x” to my search in order to highlight the correct file, and then press Return to open it.

Type the first letter of the file extension to highlight just that file.
Type the first letter of the file extension to highlight just that file.


Here are a few miscellaneous tricks that can greatly speed up your work in Xcode.

10. Move the Program Counter

When you are stopped on a breakpoint, there is a small green arrow shape that sticks out of the gutter on the left. This represents the program counter, and it points to the instruction that is about to be executed. The cool thing is that you can click and drag the program counter anywhere else in your program! This can be useful if you want to jump over a line without executing it, or perhaps go back and run a line again. With great power comes great ability to crash in new and spectacular ways, but if you’re careful, this can be a great time saver as an alternative to editing and recompiling.

You can click and drag to move the program counter to any line. When you resume execution, it will start wherever you put it. Use this power wisely.
You can click and drag to move the program counter to any line. When you resume execution, it will start wherever you put it. Use this power wisely.

11. Preview Assistant Editor

If you are using trait collections in iOS 8+ apps, your xibs and storyboards are probably all 600 × 600 pt squares, and it can be hard to visualize how they will look at different sizes. Luckily, the Assistant Editor is here to help.

Open the Assistant editor (⌘⌥↩). From the Jump Bar, choose Preview.

Pick Preview from the first menu in the Jump Bar to see a preview of your interface at different screen sizes and orientations.
Pick Preview from the first menu in the Jump Bar to see a preview of your interface at different screen sizes and orientations. (Click to embiggen.)

This will give you a preview pane with a device-specific view of your interface. You can click the + button at the bottom to add more screen sizes, allowing you to test your layouts with different widths, heights, and aspect ratios.

The Preview pane lets you see your interface on multiple devices sizes and orientations at the same time.
The Preview pane lets you see your interface on multiple devices sizes and orientations at the same time.

12. Searchable Menus

On a Mac, you can open a popup menu and type the first few letters of an item to jump to that item. You’ve probably used it to find your state or year of birth on Web forms. However, Xcode menus go one better. Most menus in Xcode are fully searchable. Just start typing, and a search field will appear, filtering the menu down by the characters you’ve typed. And the best part is that searchable menus employ the same fuzzy matching as the Open Quickly dialog.

A great use of searchable menus is in the Show Document Items menu, which you can activate using ⌃6. This menu, which appears from the Jump Bar, shows all the classes, properties, and methods in the current file. It also shows dividing lines and section markers that you’ve inserted manually using #pragma mark – Section Name.

Press ⌃6 to show a list of all classes, methods, and properties in your file.
Press ⌃6 to show a list of all classes, methods, and properties in your file.

Just start typing, and you can quickly filter this menu to select the item you want:

Many menus in Xcode allow typing to filter their contents.
Many menus in Xcode allow typing to filter their contents.

13. Alcatraz

Alcatraz is a package manager for Xcode. It lets you browse and easily install plugins, templates, and color schemes. I mentioned Alcatraz in the talk, but I wanted to use the extra space here to list some of my favorite Xcode plugins.

  • DerivedData Exterminator
    As your project grows, Xcode seems to lose its ability to keep track of all the files and sub-projects that make up your app, and various build products seem to get stale and need to be blown away. This plugin puts a button in the Xcode toolbar that makes it a snap.
  • FuzzyAutocomplete
    This plugin supercharges Xcode’s CodeSense autocomplete system by adding fuzzy matching, just like you can already use in Open Quickly and searchable menus. It’s particularly good for Objective-C code, which often has many elements with long, similar names that differ only near the end. With FuzzyAutocomplete, if you’re trying to type a name like UIViewAutoresizingFlexibleTopMargin, you can just type, for example, flextop. FuzzyAutocomplete takes care of the rest. I filed a radar for Apple to incorporate this into Xcode, because it should work like this out of the box.
  • GitDiff
    Xcode’s Comparison view is useful for seeing which lines have Git status, but it’s also cumbersome (it takes up half your screen). GitDiff provides a lightweight alternative: small colored bars that live in the gutter alongside line numbers and breakpoints. When I’m using it, I have a clear and unobtrusive reminder of which lines I’ve edited, which can help me to keep track of what I’m currently working on.
  • SCXcodeSwitchExpander
    Type a switch statement, and this plugin will write all the cases for you, based on the values defined in your enumeration. Another one that should be built in.
  • VVDocumenter-Xcode
    Type /// above any method or property, and this plugin will transform it into a formatted documentation comment, complete with placeholder parameters for the arguments and return value. Best of all, these comments work with the ⌥ Click documentation popover trick described above.
  • XVim
    Vim shortcuts and editing modes in Xcode. Useful if you like pain. (Can you tell I’m not a Vim user? But it’s super powerful if you already know the shortcuts.)

What Are Your Favorites?

I hope these tips and tricks have been helpful. There is so much more depth and breadth to Xcode than the small amount I was able to cover here. What are your favorite tips and tricks? Post them in the comments below!

Interested in joining the Raizlabs team making great software? We’re hiring developers in Boston and SF.


  1. Thanks! I picked up a couple of great new tips! One of my most used shortcuts is to command + option + shift + click on a target to open the destination picker. Then either click on your desired destination or use the arrow keys (command + arrow keys to switch windows) to navigate around and press enter to select a destination. Now I gotta get me some of those peppers!

  2. Concerning navigation, one essential thing Xcode is missing though: jumping to previous cursor positions _in_the_same_file_. Scenario: edit something, need to add an import on top, then go exactly where you were. Missing that is show stopper for me.

  3. @Scott Gardner: great tip! I love the destination picker. It feels like it would be too fiddly at first, but it’s an excellent way to quickly throw a file into a new tab or screen.

    @elmotron I miss it too. I feel like I can sometimes get a “back” navigation action to go back to where I was editing, but I just tried and couldn’t get it to work. Here’s what I do as a workaround: if I’m somewhere in a file and I know I need to jump to the top for an import, I write some garbage or leave a line unfinished, so that I get an inline compiler error. After I make my edit at the top of the file, I use ⌘’ (Command-apostrophe) to Jump to Next Issue, which brings me back to the line of code that I broke.

    Additionally, if you have GitDiff installed via Alcatraz, you can see little marks in the gutter on lines that are modified since the last commit. Not useful in a new file, or in a file with lots of changes, but sometimes it can be just the trick for getting back.

    And finally, you may want to check out – I don’t use it myself, but if you like Sublime Text’s map view, this may be a good way to find your place in a long file.

    1. You can also use ^@ to set a mark and then ^X^X to go back to it when needed (only moves cursor, cmd-shift-L to scroll to cursor).

      Someone should write an extension for this stuff.

  4. this is great! tho I think u are missing one of the most important things to shortcut in xcode, the debugger!. I changed play, step over, step in and step out action to ⌘1, ⌘2, ⌘3, ⌘4 and debugging is much easier (notice that u will loose the old functionlaity of those combinations, but I didn’t use them as much anyway)

  5. My favorite Xcode feature is the nonexistent “adjust line spacing” keyboard shortcut, which allows you to adjust the line spacing in the code editor. I love Apple’s stubbornness when it comes to (not) implementing common sense features.

Leave a Reply

Your email address will not be published. Required fields are marked *