In this article, we’ll explore some of the Xcode configurations and shortcuts that I find most useful and that can save you time and effort when working on your projects.
Table Of Contents:
Xcode Configurations
1. Check Spelling While Typing
I love this one, it makes finding/preventing/fixing typos so much easier.
To enable it, go to: Edit -> Format -> Spelling and Grammar -> Check Spelling While Typing
Then Xcode will underline with a red line the words with typos.
2. Disable print
keyboard binding shortcut
The default keyboard shortcut for printing
the code (IN PAPER!!) is ⌘ + P
, which is really close to our beloved ⌘ + ⇧ + O
, and sometimes we hit it by mistake.
A quick solution for that is to change or remove the binding of the print
action.
Double click on the key column and replace or remove the binding:
3. Use ⌘ + Click
to jump to definition
4. Text Editing Configurations
5. Play sound on succeeded build
One quick way to know that a build was successful is to make Xcode reproduce a sound:
Shortcuts
macOS
- Custom:
⌘ + ⇧ + S
→ Select area + screenshot + copy it to clipboard (Check how to add it in this article) ⌘ + ⌃ + Space
→ Open Emoji Keyboard^ + →
→ Move one space to the right^ + ←
→ Move one space to the left^ + ↑
→ Open Mission Control⌘ + Space
→ Open Spotlight Search⌘ + delete
→ Send item to trash⌘ + ⇧ + delete
→ Empty trash⌘ + ⌥ + W
→ Close all windows- With
FlyCut
installed:⌘ + ⇧ + V
(Access Clipboard history)
Typing
⌥ + delete
→ Delete entire word⌘ + delete
→ Delete entire line
Finder
⌘ + ⌥ + W
→ Close all windows
Safari
⌘ + L
→ Focus on the address bar⌘ + T
→ New tab⌘ + ⇧ + T
→ Reopen closed tab⌘ + R
→ Refresh
Notion
⌘ + K
→ Global Search⌘ + T
→ New File⌘ + R
→ Refresh
Xcode
⌃ + ⇧ + Click(s)
→ Multi Cursor on selected clicks^ + ⇧ + Drag click
→ In-line Multi Cursor-
^ + M
→ Format to Multiple Lines ⌘ + 0
→ Hide/Show the Navigator (Left panel)⌘ + ,
→ Open Settings⌘ + ;
→ Check next typo in the current file⌘ + L
→ Go to line Number⌘ + N
→ New File-
⌘ + Y
→ Disable/Enable breakpoints ⌘ + ⇧ + J
→ Display and select current file in the folder hierarchy⌘ + ⇧ + O
→ Open file/method/struct quickly-
⌘ + ⇧ + Y
→ Show/Hide Debug Area (Console) ⌘ + ^ + ←
→ Back to previous file⌘ + ^ + →
→ Forward to next file⌘ + ^ + E
→ Edit All in Scope (Rename in Scope)⌘ + ^ + L
→ Show/Hide all issues-
⌘ + ^ + T
→ New Editor to the right ⌘ + ⌥ + 0
→ Hide/Show the Inspectors (Right panel)⌘ + ⌥ + /
→ Add docs template to the selected method/property⌘ + ⌥ + ]
→ Move line up⌘ + ⌥ + [
→ Move line down⌘ + ⌥ + W
→ Close all tabs but the current one
Xcode combos
- Rename a file:
Highlight the new name
⌘ + C
→ Copy⌘ + ⇧ + J
→ Display and select current file in the folder hierarchyEnter
→ Edit the file name⌘ + V
→ PasteEnter
→ Save the new name
- Indent file:
⌘ + A
→ Select All^ + I
→ Indent file
- Add a new Editor (and space):
⌘ + ^ + T
→ New Editor to the right⌘ + 0
→ Hide/Show the Navigator (Left panel)⌘ + ⌥ + 0
→ Hide/Show the Inspectors (Right panel)⌘ + ⇧ + Y
→ Show/Hide Debug Area (Console)
- Search a file and display it in a new editor:
⌘ + ⇧ + O
→ Open file/method/struct quickly- Type the name of the file
- Hold
⌥
and pressenter
- Open a file from the project navigator in a new editor (This one is specially useful for Views/ViewModels):
- Hold
⌥
- Tap on the file
- Hold
Custom Keybindings
A list of the keybindings that I usually add/replace on Xcode.
To do that, press ⌘ + ,
on Xcode, go to the Key Bindings
tab and just search for the actions.
⌘ + ⇧ + E
→ Refactor → Rename. When adding this one, you have to remove it from its default action:Use Selection for Replace
. Given I don’t use that action, I can remove the keybinding.
Time Savers
Xcode Templates
Create your own Xcode templates for your files
Console Aliases
I also like to have some handy aliases for the console. Here is a step by step guide on how to create aliases.
Remove derived data folder
alias rmdd='rm -rf ~/Library/Developer/Xcode/DerivedData'
Then you can just type the rmdd
command on your console, and it will remove the DerivedData folder.
Change directory to your project folder
alias cdp='cd ~/projects/your-project/'
Then you can just type the cdp
command on your console, and it will change the directory to your project directory.
Automatic Formatter
alias pformat='cd ~/projects/your-project/ && swift run -c release swiftformat --swiftversion 5.7'
Then you can just type the pformat
command on your console, and it will run the formatter on your project.
Find typos
Follow the steps in the SwiftTypoDetector article.
Then just run typos
in the terminal.
Conclusion
In conclusion, these Xcode configurations and shortcuts are just a few examples of how customizing your development environment can help you work more efficiently and effectively. Whether you’re a seasoned iOS or macOS developer or just starting out, taking the time to optimize your IDE can make a big difference in your productivity and satisfaction with the development process. So give these configurations and shortcuts a try, and don’t be afraid to experiment with your own customizations to find what works best for you.