Our Favorite Xcode Shortcuts

Michael Gachet
BPXL Craft
Published in
5 min readJan 30, 2017

--

We recently had a conversation in our developer channel on Slack about our favorite Xcode keyboard shortcuts. This colorful exchange led to the interesting realization that:

  1. Most of our favorite Xcode shortcuts deal with efficient code navigation and editing.
  2. Each one of us learned at least one shortcut we did not know existed.

This last point nudged us into writing this article to share the Xcode shortcuts that we feel best help boost our productivity.

A refresher on Xcode’s different areas.

Our favorite shortcuts focus on three key areas:

  • The navigator area on the left where you can see your file structure.
  • The editor area in the center where code editing takes place.
  • The utilities area on the right where you can further inspect your files or UI.

Some of the editor area shortcuts deal with the jump bar at the top of the editor itself.

1. Edit all in scope: CTRL+⌘+E

This shortcut allows you to change the name of a variable or function and have that change take effect in your entire file. Here is an illustration:

Before

After

We simply clicked on `label` within the `set` method, typed ⌘+CTRL+E, and changed the name to `titleLabel`.

2. Fix all in scope: CTRL+⌥+⌘+F

This one is a handful, but it’s super handy. It will allow Xcode to automatically fix all errors that can be fixed automatically.

3. Open quickly: ⇧+⌘+O

Type ⇧+⌘+o and start typing in the search box that opens. The strength of “open quickly” is that the search engine is able to discern which files or functions you’re looking for even if you only enter parts of the name. For example, typing “appfinish” will bring up “applicationDidFinishLaunching” as part of the results.

4. Searching within a file: CTRL+6

This powerful shortcut opens the jump bar so you can see all existing symbols in the open file and search for the symbol you are looking for. Let’s look at an example of how it works.

Here is the jump bar:

Type CTRL+6:

Here’s where you type the name of the symbol you are looking for:

To make this shortcut more powerful, use CTRL+1–6 to open any part of the navigation hierarchy and start searching through it.

5. Jumping to a symbol definition

There are two ways to jump to a symbol definition:

  • ⌘+Click on the symbol to jump to its definition in your current editor window.
  • ⌘+⌥+Click on the symbol to open the symbol definition file in the assistant editor.

Below is the result of ⌘+⌥+Click on the `super.viewDidLoad()` symbol in our main editor. It opened the assistant with the `super` class definition of `viewDidLoad()`.

6. Open in…

Use ⌥+⇧ with any file or symbol action to bring up an “Open in…” UI and choose where to open this file or symbol.

For example, performing ⌘+CLICK+⌥+⇧ on a symbol will bring up the following UI:

7. Switching assistant editor

Since we just saw how to open a symbol in the assistant editor, here are three shortcuts to rapidly switch the editor:

  • ⌘ + Enter opens the standard editor (single window).
  • ⌘ + ⌥ + ENTER opens the assistant editor.
  • ⌘ + ⌥ + ⇧ + ENTER opens the source control editor.

8. ⌘+⇧+J

In a typical project hierarchy it can be easy to lose track of where you are in your file tree structure. ⌘+⇧+J will help you by highlighting the file you are currently editing.

9. ⌘+0

Use ⌘+0 to toggle the navigator visibility and ⌘+1–8 to switch to any of the navigator tabs.

10. ⌘+⌥+0

The utilities area can be easily hidden or shown using ⌘+⌥+0. Add ⌘+⌥+1–3 to open one of the utilities tabs.

11. ⌘+⇧+⌥+K

If you are working with Swift and indexing or Source Kit is causing you grief a fast way to nuke your index and target resources is to use ⌘+⇧+⌥+K. This is the last step before removing your derived data folder.

We hope you find these shortcuts as useful as we do. Some of them, once discovered, are never forgotten. Others take a bit of time to get used to. Let us know what you think and share your favorite Xcode shortcuts with us in the comments.

For more insights on design and development, subscribe to BPXL Craft and follow Black Pixel on Twitter.

Black Pixel is a creative digital products agency. Learn more at blackpixel.com.

--

--

Michael Gachet
BPXL Craft

Curious mind, iOS developer, runner. All views are mine...