everyday-use.md

Everyday use

This page is a tour, meant to be followed with Xcode open next to it. Each section introduces one group of keys and gives you a few things to try. You don't need to learn them all: pick the two or three you'd use today, and the which-key panel will remind you of the rest.

Everything below starts with the leader. When you read m r, press ⌥↩ first, then m, then r. An uppercase letter means with Shift: c D is c, then Shift-d. The command reference lists every key.

How the keys are organised

The first key after the leader picks a group, named after what it's about. The second key picks a command inside it.

Key Group Key Group
b buffers (open files) n navigator (left pane)
c code p project
d debug q quit
f files s search
g git t toggles
h help T ui (appearance)
i inspector (right pane) w windows and panes
m make (build, run, test) x text

Inside a group, the same idea repeats: the letter is usually the first letter of the command (m t tests, g p pushes), and Shift gives a variation (m T runs the tests again).

If you've used Doom Emacs or Spacemacs, this will feel familiar: the layout follows theirs wherever Xcode has an equivalent. If you use Vim, the pane keys follow Vim's ⌃w.

Opening files

Keys What it does
SPC Find a file in the project
, Switch to an open file, or one you had open recently
. Xcode's own Open Quickly
f r Open a recent project
c a Jump to the counterpart (header ↔ implementation, and other related files)

Try it: press ⌥↩ SPC, type a few letters of a file name, and press Return. The letters don't have to be next to each other: apdl finds AppDelegate.swift. Files you open often move to the top.

Pickers

The file finder is a picker: a list you filter by typing. XCommander has several (files, open editors, symbols, schemes, destinations, themes, project search, and the command palette), and they all work the same way:

Key What it does
Type Filter the list. Letters can be spread out: bldt matches "Build Documentation".
↓ ↑, ⌃n ⌃p, ⌃j ⌃k, Tab Move the selection
Return Choose the selected row
Esc or ⌃g Close the picker
⌃u Clear what you typed
⌃w or ⌥⌫ Delete the last word
⌃a ⌃e, Home End Jump to the first or last row
Page Up Page Down Move a page at a time

The command palette

⌥↩ : opens the command palette: every command XCommander knows and every item in Xcode's menus, several hundred of them, in one searchable list.

Try it: open the palette and type minimap. You'll see Xcode's Minimap menu item, and next to it the XCommander keys for it (t m). That's the palette's second job: whenever you reach for a command, it shows you the keys, so next time you can skip the palette.

Build, run and test

Keys What it does
m m Build
m r Run
m t Test
m T Test again (the last tests you ran)
m k Stop
m c Clean the build folder
p s Choose a scheme
p d Choose a run destination (Mac, simulator, device)

Try it: p d, type pro max, Return, then m r. You've picked a simulator and run your app without opening Xcode's long destination menu.

Moving around code

Keys What it does
c d Jump to the definition of the symbol under the cursor
c D The same, in the next editor pane
c o / c O Go back / forward
c s Jump to a symbol in this file
c S Jump to a symbol anywhere in the project
c c Show who calls this
c n / c p Next / previous issue (errors and warnings)
c h Quick Help for the symbol under the cursor

Try it: put the cursor on a type name, press c d to jump to it, look around, then c o to come straight back.

The symbol pickers read Xcode's index, so they're empty until Xcode has indexed the project. Building it once makes sure.

Editing code

Keys What it does
c r Rename (Xcode's refactoring, across files)
c e Edit all occurrences in scope
c / Comment or uncomment
c f Format the file
c u / c j Move the line up / down
c v Extract to a variable
c m Extract to a method
c x Fix all issues Xcode can fix

Searching

Keys What it does
/ or s g Search the whole project, with a preview
s s Find in this file
s p Xcode's Find in Project
s r Find and replace
s n / s N Next / previous match

Try it: ⌥↩ / and type a word from your code. Each result is one line; the pane on the right shows the lines around it, coloured, and moves as you go up and down the list. Return opens the file at that line. (This uses ripgrep; see Getting started. The preview only appears when Xcode's window is wide enough for it, which you can change in Settings.)

Panes and windows

Xcode can split its editor into several panes. XCommander lets you work with them by direction, and adds two things Xcode can't do: swap two panes, and send a file to another pane.

Keys What it does
w v / w s Split: new pane to the right / below
w h j k l Move to the pane left / below / above / right
w x Swap this pane's file with the next pane's
w H J K L Send this file to the pane left / below / above / right
w = Make all panes the same size
w z Zoom: make this pane take the whole editor, and back
w d or w q Close this pane
w o Close every other pane
w n / w i / w b Show or hide the navigator / inspector / debug area

Try it: w v to split, SPC to open another file in the new pane, w h to go back to the left pane, then w x to swap them.

w W is a sub-group for the macOS window itself: tile it left or right, fill the screen, merge windows.

The navigator and the inspector

Keys What it does
n p Show the Project navigator
n f Put the keyboard in the navigator, to move through it with the arrow keys
n / Filter the navigator
n i / n t / n k Issues / tests / breakpoints navigator
i i Show or hide the inspector
i h The History inspector (who changed this file, and when)

Git

Keys What it does
g c Commit
g p Push
g F Pull
g f Fetch
g s / g u Stage all / unstage all
g z Stash

Commit, push and pull open Xcode's own sheets, so you still see what you're about to send.

The debugger

Keys What it does
d p Pause or continue
d o Step over
d i / d u Step into / out
d c Continue to the line with the cursor
d b Turn all breakpoints off or on
d C / d v Put the keyboard in the console / the variables view

Text

The x group changes the selected text. With nothing selected, it works on the line the cursor is on. ⌘Z undoes it, like any other edit.

Keys What it does
x a Align lines on a delimiter (=, :…)
x s / x S Sort lines / in reverse
x d Remove duplicate lines
x j Join lines
x w Trim trailing whitespace
x u / x l UPPER / lower case
x c / x _ camelCase / snake_case

Try it: select a few let lines with = in them and press x a.

Toggles and appearance

Keys What it does
t v Xcode's Vim mode on or off
t m Minimap
t w Wrap lines
t i Show invisible characters
t a Authors (blame)
T + / T - / T 0 Bigger / smaller / default font size
T t Choose an editor theme

XCommander itself

Keys What it does
q q Quit XCommander
q r Re-read Xcode's menus (your configuration file reloads by itself when you save it)
h c Check that every key still finds its command in your Xcode
q X Quit Xcode

Where to go from here