Useful keyboard shortcuts when using Xcode!

Tram Ho

If your job requires you to work with the IDE for eight hours a day , using keyboard shortcuts can save you eight working days a year .

Here are 13 useful keyboard shortcuts for programmers who use Xcode 8 hours a day ?

Basic keyboard shortcuts

  • Build : ⌘ + B
  • Run : ⌘ + R
  • Test : ⌘ + U
  • Stop : ⌘ +.
  • Clean : ⌘ + ⇧ + K
  • Clean the build folder : ⌘ + ⇧ + ⌥ + K
  • Open quickly : ⇧ + ⌘ + O
  • Code completion : ⌃ + Space

Shortcuts to Editors

  • Add a screen editor : ⌃ + ⌘ + T (Control + Command + T)
  • Focusing on an existing screen editor : ⇧ + ⌃ + ⌘ + ↩ (Shift + Control + Command + Enter)

Fix all errors in the file

  • ⌃ + ⌥ + ⌘ + F (Control + Option + Command + F)

This section is quite useful because of syntax-related errors in Swift, or changes in files that have not been updated yet. This function works quite well and saves relatively time with large projects.

Multiple Cursors

Select the word you want to apply multiple cursors. Then press

  • ⌥ + ⌘ + E (Option + Command + E)

To move the cursor to the previous position use ** Shift + Option + Command + E **

Refactor

⌃ + ⌘ + E (Control + Command + E) Allows editing of variable names in all files at once.

Fold / Unfold Method

  • Fold All: ⇧ + ⌥ + ⌘ + ← (Shift + Option + Command + Left Arrow)
  • Unfold All: ⇧ + ⌥ + ⌘ + → (Shift + Option + Command + Right Arrow)
  • Fold Current Block: ⌥ + ⌘ + ← (Option + Command + Left Arrow)

SwiftUI Previews

SwiftUI has changed the way we think and build UI. With the built-in canvas preview in Xcode, building user interfaces through code or directly in the preview has become a lot easier.

Toggle canvas

  • ⌥ + ⌘ + ↩ (Option + Command + Enter)

If you’re looking to quickly build a prototype in code without letting live previews distract you until it’s done, here’s a handy shortcut.

To continue working with the live preview we use a combination

  • ⌥ + ⌘ + P (Option + Command + P)

Mini map

Xcode 11 has given us a miniature map. A very essential outline view of your code on the right side of the IDE. By hovering over it, you can navigate to any part of your code.

  • Toggle Minimaps: ⇧ + ⌃ + ⌘ + F (Shift + Control + Command + F)
  • Minimap Outline: ⇧ + ⌃ + ⌘ (Shift + Control + Command)


Refer

Share the news now

Source : Viblo