Increase your Productivity by using these Xcode Keyboard Shortcuts

Increase your Productivity by using these Xcode Keyboard Shortcuts

As a developer, I really don't prefer using trackpad or mouse when I'm in a middle of writing code's lines. Fortunately Xcode has a punch of built in Keyboard shortcuts to keep you focused on using the Keyboard, I'll try to mention the most useful ones but you can always review the full list from within Xcode itself by going to Xcode->Preferences->Key Bindings.

File Shortcuts

  • You can create new File easily by hitting Command+N (?N), but make sure you are in the right hierarchy in Project Navigator.
  • Creating new Group/Folder can be done using Option+Command+N (??N), also check the hierarchy beforehand.
  • Shift+Command+N (??N) will create a new project for you.

View Shortcuts

There are main three shortcuts here to give you more spaces depending on your situation by showing and hiding the main parts of the Xcode UI (Navigator, Debug Area and Inspector), we will see them in details below:

  1. Showing/Hiding the Navigator can be toggled through Command+0 (?0), furthermore you can navigate between the Navigator tabs from Project Navigator to Report Navigator by Command+1...9 (?1...9) prospectively.
  2. The right side (the Inspector) can show/hide by using Option+Command+0 (??0), and navigation between its tab can be done by the same way as in the left side using Option+Command+1...3 (??1...3).
  3. The last part is the bottom one which is the Debug Area, you can show/hide it by Shift+Command+Y (??Y).
  4. There is a hidden part of the UI that you will use frequently, I think you guessed it, right! The Library, from there you can add UI elements in Story Boards and/or SwiftUI Preview and Code. You can bring up the Library by Shift+Command+L (??L).
  5. You can enter/exit Fullscreen mode by Control+Command+F (??F)

Editor Shortcuts

I found this group is the most useful for me, since it helped directly in editing my code base. Let's start seeing them:

  • To show/hide the Assistant Editor you can use Control+Option+Command+Return (?????).
  • There is a new part came exclusively in macOS Catalina 10.15, which is the Canvas (The Preview), in order to show it you need to hit Option+Command+Return (????), and to hide it you can use the same combination you used to bring it or alternatively you can use Command+Return (???).
  • To resume the preview and see the live updates you can use Option+Command+P (??P).
  • To bring up the code completion you can hit Control+Space (??).
  • Use Command+Forward Slash (?/) to comment a whole selection, and the same to uncomment the selection.
  • To format the code indent you need to select the code first then hit Control+I (?I).
  • Also after selecting the code snippet you can move it one tab forward (Shift right) by Command+Ending Square Brackets (?]), and you can move it one tab backward (Shift Lift) by Command+Starting Square Brackets (?[).
  • You can fold a code snippet by placing the cursor in it and press Option+Command+Left Arrow (??←), and to unfold it press Option+Command+Right Arrow (??→). Also to fold the whole file's methods and functions use Option+Shift+Command+Left Arrow (???←), and to unfold use Option+Shift+Command+Right Arrow (???→).

Product Shortcuts

  • To clean the build folder press Option+Shift+Command+K (???K).
  • To choose a scheme hit Control+0 (?0).
  • To edit the selected scheme use Command+Shift+Comma (??,)
  • To build the product use Command+B (?B).
  • To run the product press Command+R (?R).

Debug Shortcuts

  • To add a breakpoint move the cursor to the designated line and press Command+Back Slash (?\), and to remove it use the same shortcut.
  • To deactivate breakpoints use Command+Y (?Y).
  • To continue after a breakpoint reached hit Control+Command+Y (??Y).
  • To clear the debug console press Command+K (?K).

I know this is a long list of shortcuts and you will struggle to memorise all of them but with time you will find yourself already know must of them. Keep using the most useful for you and whenever you want to memorise a new one, use it too frequently.

You may noticed that I didn't cover the basic Edit Shortcuts, like Copy, Paste, Cut, Undo and Redo as I assume you as a developer already using those basic ones.

If you have a useful shortcut that I didn't mentioned above, don't hesitate to mention them in comments. Follow me here on LinkedIn to see my posts and tricks about iOS development topics more often, or on Medium to get access to my latest tutorials on iOS development topics.

要查看或添加评论,请登录

Jihad Fayez的更多文章

社区洞察

其他会员也浏览了