Xcode supports automated refactoring. Supposedly.
In practice, the options are limited and often unavailable. You’ll right-click something, navigate to the Refactor submenu… only to find that the command you want is grayed out. It’s a waste of time.
Eventually, you stop trying.
That’s the real problem. Xcode’s poor support for refactoring discourages people from using it at all. But I want to flip that dynamic — by making refactorings fast to access. They may not always work, but at least I know instantly. And when they do work, I’m ready to use them.
Refactorings I Trigger By Shortcut
Here are the three automated refactorings I’ve bound to custom key combinations:
- Rename — ⌃⌘N

N for name. This is the most reliable of Xcode’s refactorings. - Extract all occurrences — ⌃⌘V

V for variable. Turns a repeated expression into a variable in one shot. - Extract to method — ⌃⌘M

M for method. Clean up code by extracting a portion into a named function.
With these shortcuts, I can try an automated refactoring in less than a second. If it’s not available, I get feedback right away — no wasted mouse clicks. And when it is available, I stay in the flow.
Note: ⌃⌘N conflicts with the default key binding for New Workspace. Resolve by clearing that binding.
Other Key Bindings I Use All the Time
Here are two more that aren’t refactorings, but are absolutely worth setting up:
- Delete line — ⌘⌫

This one’s great. It deletes the entire current line, no selection needed. You won’t find this in the menu bar. Once you map it, it quickly becomes second nature. It’s much faster than triple-clicking to select, then delete. - Reformat file with SwiftFormat — ⌃⌘L

Instantly reformat the entire file. This used to be more important, before Xcode 16 added ⌃⇧I for Format File with 'swift-format'. Still handy, depending on your setup.
Note: ⌘⌫ conflicts with the default key binding for Delete to Beginning of Text. Resolve by clearing that binding.
Why It Matters
Most developers don’t use Xcode’s refactorings — because they’re buried, unreliable, and often unavailable. That creates a vicious cycle.
Custom key bindings reverse that. They make refactoring fast to try, with no penalty for failure. Sometimes they even work.
The result: You refactor more often. And that’s the real win.
Have your own favorite bindings? Or a shortcut I should be using? Let me know — I’m always looking for ways to improve my workflow.
See It In Action
I cover one of these shortcuts — renaming with ⌃⌘N — in this video from my TDD with SwiftUI series:
