212

What Xcode keyboard shortcuts do you use regularly?

I am a huge believer in using the keyboard as much as possible (its much faster that way), and I was hoping others could share some of the Xcode shortcuts they use.

memmons
  • 40,222
  • 21
  • 149
  • 183
Umair
  • 862
  • 4
  • 10
  • 16
  • 37
    A question upvoted 43 times is not constructive? – Boon Jan 22 '14 at 20:13
  • 3
    How could this solicit anything but a list of commands? – Morkrom May 14 '14 at 16:33
  • 3
    I put together a PDF of popular keyboard shortcuts: http://iphonedev.tv/blog/2014/9/25/14-xcode-keyboard-shortcuts-cheat-sheet-pdf – Paul Solt Sep 26 '14 at 05:08
  • 4
    I am surprised that none of the answers include [ctrl+6] for searching method or mark in the current file. – Yogesh Maheshwari Mar 02 '15 at 19:42
  • 3
    Eurgh it annoys me so much how useful threads get closed by the SO police... – Phil Hudson Apr 02 '16 at 04:10
  • For Xcode 9.3, go to answer given by Rein rPavi for all keyboard shortcuts. https://stackoverflow.com/questions/2828262/is-there-a-go-to-file-in-xcode – Rein rPavi Apr 09 '18 at 06:41
  • See Link by [Apple](https://developer.apple.com/library/mac/documentation/IDEs/Conceptual/xcode_help-command_shortcuts/MenuCommands/MenuCommands014.html) itself. My favorites are `Command-Shift-F` = Find in Workspace & `Command-Option-C` which will open the changes I've made & with less significance `Command-"` = Jump to Previous Issue, . Also note you can go and switch/change shortcuts. 99% of all operations can be configured to the shortcut you like. You can **replace/change** existing shortcuts to something else. Just go to Xcode >> behaviors >> key bindings – mfaani Nov 30 '18 at 14:18

16 Answers16

253

I find the shortcuts to open & close various areas of the screen must useful.

shortcuts

Community
  • 1
  • 1
Robert
  • 37,670
  • 37
  • 171
  • 213
  • Searched for this image in third time, finally saved, it's great. Always forget filters. – DanSkeel Nov 29 '12 at 17:31
  • 4
    @DanSkeel Thank you. Quick note on the navigator filter - I used to frequently use cmd-option-j to filter then navigate to source files. However now I find the open quickly command better (cmd-shift-O , type a few chars, return) – Robert Nov 30 '12 at 12:45
  • 6
    If you want to focus on search field of `Search Navigator` you can press `Command + 3` and then hit `Command + Option + j` – DanSkeel Jun 02 '13 at 09:58
  • 8
    A nice addition would be `^(1-6)` for the UI elements above the main editing area. You can easily navigate to `Recent Files`, `Callers`, and the `Method list`. Note that you can start typing after any one of those. (**Very** useful with `Control-6`.) – funroll Jun 05 '13 at 15:51
  • Does anyone know how to assign multiple Shortcuts to one action in the Xcode preferences? Some actions are pre-defined with multiple shortcuts, but I couldn't figure out how to, e.g. assign both PageUp and the default one for "Switch to next Counterpart". – Raffael Aug 08 '13 at 19:43
  • @runroll that's very useful, thanks! I And noting that you can type into those is great. It's not clear from any UI indications that typing works, but it does. #noComplaints – Dan Rosenstark Apr 15 '16 at 17:14
  • What button is used to access the main editor? I can see that a key is cmmd, I don't know what the other is. I tried shift,option, arrows, enter, delete. Still not sure... – mfaani Oct 29 '16 at 22:18
  • @Honey - ⏎ is the return key. cmd-enter will get rid of any split view and just show the main editor. – Robert Oct 31 '16 at 12:44
  • @Robert correct. Yet it won't bring the cursor the maid editor. How can I do that? – mfaani Oct 31 '16 at 12:49
  • Nobody mention cmd + ctrl + left/right arrow. its navigating forward and backward – Ccr Nov 18 '16 at 06:58
  • After I hit `cmmd + 0` I want to just use the arrow keys to go up and down from the current selected file....is there anyway to do that? – mfaani Aug 08 '17 at 18:50
138

Cmd + Shift + o opens the "Open quickly" dialog, where you can quickly find and open files that contain the text you enter.

mrgrieves
  • 567
  • 5
  • 19
Ludvig A. Norin
  • 5,115
  • 7
  • 30
  • 34
61

Updated for newer versions:

Control + Command +

Switches between corresponding .h / .m files or as Apple's own documentation, it means Jump to Counterpart

mfaani
  • 33,269
  • 19
  • 164
  • 293
Darren
  • 25,520
  • 5
  • 61
  • 71
47

command + shift + j

Reveals the current file in the project navigator. Very useful if you use command + control + J to jump to a definition as Xcode won't automatically reveal the containing file in the navigator.

Supun Wijerathne
  • 11,964
  • 10
  • 61
  • 87
Andy
  • 14,260
  • 4
  • 43
  • 56
42

command /

Comment out the current line, or multiple lines if they're highlighted.

Comes in handy for quick commenting and uncommenting while experimenting with code.

Sanjay Chaudhry
  • 3,181
  • 1
  • 22
  • 31
27

Re-indent. It's in Edit > Format > Re-Indent and there's no shortcut by default (I use Command + Shift + L). It's a godsend.

Jasper
  • 2,166
  • 4
  • 30
  • 50
jbrennan
  • 11,943
  • 14
  • 73
  • 115
25

command F Search in the File

option command F Search & Replace in the File

shift command F Search in the whole project

shift option command F Search & Replace in the whole project

Notice the pattern for easy memorizing.

Sanjay Chaudhry
  • 3,181
  • 1
  • 22
  • 31
  • 5
    After Search in Project, once the results are in the Navigator, how can you iterate through them without having to use the mouse? (I hate having to click on each result) – tothemario May 02 '14 at 22:33
  • 2
    Additionally, you can use Cmd + E to put the current selection in find (in file), and Cmd + G to select/jump to the next occurrence (Cmd + Shift + G moves backwards). Works great for quick replaces too (Alternating Cmd + G and Cmd + V). Personally I also mapped Cmd + Option + E to find selection in project, for consistency with the above. – Patrick Pijnappel Apr 11 '15 at 06:50
  • @tothemario You can hit command-option-G to move to each project-level search result. shift-command-option-G will move back through each result. – Canucklesandwich Apr 07 '17 at 19:46
  • 1
    @tothemario currently it's `Cmmd + Control + G` for next & `Cmmd + Control + Shift + G` for previous. If you want the key combination then go to Preferences >> Key Bindings >> search for 'Find Next in Workspace' & Find Previous in Workspace' – mfaani Feb 18 '19 at 22:04
20

Ctrl + Command + - Switch between header and implementation files.

Jasper
  • 2,166
  • 4
  • 30
  • 50
BlackTigerX
  • 6,006
  • 7
  • 38
  • 48
14

Command + J (Move focus to any section of the editor)

Jian
  • 10,320
  • 7
  • 38
  • 43
12

Control + Command + j

Highlight a keyword (method name) and jump to its definition. Also works for variables, #defines, etc.

Sanjay Chaudhry
  • 3,181
  • 1
  • 22
  • 31
7

Some of my favorite shortcuts are not keyboard shortcuts at all, but multitouch gestures. All Macbooks from early 2008 onward, and I would imagine desktops with a Magic Mouse or Magic Trackpad, support three-finger-swipe up and down to switch between the header and implementation, and three-finger-swipe left and right to navigate within the file history.

Jeffrey Wear
  • 1,155
  • 2
  • 12
  • 24
7

Command + Shift + Y for the console.

Arkku
  • 41,011
  • 10
  • 62
  • 84
Fabiano Francesconi
  • 1,769
  • 1
  • 19
  • 35
6

I find a cheat sheet next to the computer is the best way to pick up useful shortcuts. Cocoa Samurai has a good one.

Jonathan Moffatt
  • 13,309
  • 8
  • 51
  • 49
4

Key Bindings to XCode Actions

Create your own keyboard shortcuts using the Text Key Bindings tab of the Key Bindings preference pane. A time-saver all its own. Just lookup your favourite actions and add/edit shortcuts!

Another thread you may find useful is here.

Community
  • 1
  • 1
Old McStopher
  • 6,295
  • 10
  • 60
  • 89
3

Just the basic emacs navigation. Feels so right.

tommyo
  • 531
  • 4
  • 10
1

I cannot live without three finger vertical swipe to switch between interface and implementation file. If you miss that in xcode-4/Lion, make sure to follow the following instructions:

http://geeksinkilts.com/?p=67

Sanjay Chaudhry
  • 3,181
  • 1
  • 22
  • 31