Xcode Tips 💡

The more you know... 😎

⬅️ Go Back

✏️ Contribute

Keyboard Shortcuts

Cheatsheet

A handy list of Xcode keyboard shortcuts.

Source: Keith Harrison

Jump to a specific line

Open the file you want. Press ⌘L, type a line number and Xcode will jump directly to that line.

Re-indenting/Formatting code

Press ⌃I to apply Xcode’s indentation and formatting.

Adding comments quickly

Use ⌘/ to toggle comments for the current line or selection. Use ⌥⌘/, pressed directly before a method to have Xcode generate a documentation comment.

Source: Paul Hudson

Jump to file in source navigator

Press ⌘⇧J to quickly jump to the current open file in the navigator to easily see and select related files.

Source: Jeroen Leenarts

Open the jump bar

Press ⌃6 to open the symbol jump bar in Xcode. Now start typing. Try it, jumping to a function in the current file, never has been so easy.

Source: Jeroen Leenarts

Remapping unhelpful keys

Some great shortcuts (e.g. ⇧⌘O for Open Quickly) are next to useless shortcuts (⇧⌘P, for the never times you want to print code.) It takes only seconds to remove unhelpful keys, and you can even remap things like ⌘P to resuming SwiftUI’s preview.

Source: Paul Hudson

Increase or decrease editor font size

Press ⌘+ to increase and ⌘- to decrease.

Move cursor to the top or bottom of the file

Press ⌘↑ to move to the top of the file. Press ⌘↓ to move to the bottom of the file.

Show and hide debug area

Press ⌘⇧Y to open and close the debug area.

Generating an interface file

Press ⌃⌘⇧ to display a generated interface, showing properties, function signatures, and comments for a type. Press it again, to jump to tests for that file if they exist.

Source: Paul Hudson

Trigger Custom Behaviors

If you find yourself wasting time continually opening and closing the Navigator, Inspectors, or the Preview when you switch the type of file you’re working on, you can define custom Behaviors and assign keyboard shortcuts to them.

Xcode Behaviors set the state of the Xcode interface when events occur such as a build starting. Custom Behaviors allow you to define your own triggers.

Now you can quickly set the state of your panels to focus on the type of work you’re doing.

Source: Erwin Mazariegos

Open Human Interface Guidelines

Press ⌘⇧H to open the Human Interface Guidelines in your web browser.

Show/hide the preview canvas

It takes up a lot of space, you can quickly toggle it.

⌘ ⌃ ↵ Editor menu > Canvas

Source: Sarun Wongpatcharapakorn

Refresh Preview Canvas

If you type too fast Xcode can stop updating the preview, so you may have to trigger a refresh.

⌘ ⌥ P Editor menu > Canvas > Refresh Canvas

This will refresh your preview and start automatically updating again.

Source: Sarun Wongpatcharapakorn

Move line of code up or down

You can use a keyboard shortcut to move a line of code up or down, which can be useful for re-ordering things. This can be the current line or you can select multiple lines to move together.

To move line of code up:

⌘ ⌥ [ Editor menu > Structure > Move Line Up

To move line of code down:

⌘ ⌥ ] Editor menu > Structure > Move Line Down

Source: Sarun Wongpatcharapakorn