⬅️ Go Back
✏️ Contribute
A handy list of Xcode keyboard shortcuts.
Source: Keith Harrison
Open the file you want. Press ⌘L, type a line number and Xcode will jump directly to that line.
Press ⌃I to apply Xcode's indentation and formatting.
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
Press ⌘⇧J to quickly jump to the current open file in the navigator to easily see and select related files.
Source: Jeroen Leenarts
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
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
Press ⌘+ to increase and ⌘- to decrease.
Press ⌘↑ to move to the top of the file. Press ⌘↓ to move to the bottom of the file.
Press ⌘⇧Y to open and close the debug area.
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
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.
- Go to
Xcode -> Preferences
- Open the
Behaviors
tab - Click
+
at the bottom of the list and name the new Behavior (E.g.IB File
,Code File
,SwiftUI File
) - On the right side, set the state of the
Navigator
,Inspectors
,Preview
or other elements - Assign a keyboard shortcut next to each name
Now you can quickly set the state of your panels to focus on the type of work you're doing.
Source: Erwin Mazariegos
Press ⌘⇧H to open the Human Interface Guidelines in your web browser.
It takes up a lot of space, you can quickly toggle it.
⌘ ⌃ ↵
Editor menu > Canvas
Source: Sarun Wongpatcharapakorn
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
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