When we use a tool every day it is easy to get so used to certain movements that we sometimes forget to think about how we can make our daily work more efficient and more effective. Especially shortcuts or rather the habit of using them as often as possible is a tool we can use to get our work done faster and to concentrate on the most important things. Even though, I know this list by far does not contain all useful shortcuts, these are my most used shortcuts in Xcode:
1. Jump to a specific file aka “Open quickly”
⌘ + ⇧ + O
2. Jump to a specific line in a file
⌘ + L
3. Search in a file
This is not for looking up some text (⌘ + F) but for looking up e.g. a method name or something similar.
⌃ + 6
4. Search for a piece of text in the whole project
⌘ + ⇧ + F
5. Rename file in scope
⌘ + ⌃ + E
6. Comment line out
Just mark the line(s) you want to comment out. Do the same when you want to uncomment some line(s).
⌘ + /
Marking some part of your code and apply something to the marked section not only works for comments. It also works for surrounding a section with:
7. Move line up or down
Move line up
⌘ + option + [
Move line down
⌘ + option + ]
8. Go back and forward between files
Go forwards in files
⌘ + ⌃ + →
Go backwards in files
⌘ + ⌃ + ←
9. Show file in hierarchy
⌘ + ⇧ + J
10. Run all tests
⌘ + L
Especially when you use SwiftUI this shortcut will come be even more handy. Do the following on a class or function name.
⌘ + ⌃ + [click]
This will open a sub menu with different options. In this short article I want to pull your attention to two of them:
This will show all types that call the clicked element. Which it’s great for debugging for example.
This enables you to rename the clicked element in the whole project.
You can read this post on my blog as well