Sub topic 11
Control-key text shortcuts from the Emacs tradition
This chapter assumes you know the modifier symbols (⌘, ⌥, ⌃, ⇧) and the arrow-key movement shortcuts from the earlier chapters. It adds a second set of text-editing keys that works in almost every Mac text field.
Why these shortcuts exist
macOS text fields share a system-wide text engine. That engine understands a set of ⌃ (Control) shortcuts borrowed from Emacs, a text editor popular on Unix systems. You get them in Notes, Mail, Messages, Safari's address bar, TextEdit, and most other apps that use standard text fields.
Their main benefit is that your hands never leave the letter keys. You do not reach for the arrow keys or the Delete key.
The core set
Each key is a mnemonic for the action it performs.
| Shortcut | Action | Memory aid |
|---|---|---|
| ⌃A | Move to start of line | **A**t the beginning |
| ⌃E | Move to end of line | **E**nd |
| ⌃F | Move forward one character | **F**orward |
| ⌃B | Move back one character | **B**ackward |
| ⌃N | Move to the next line (down) | **N**ext |
| ⌃P | Move to the previous line (up) | **P**revious |
| ⌃D | Delete the character to the right | **D**elete |
| ⌃H | Delete the character to the left | Same as Backspace |
| ⌃K | Delete from the cursor to the end of the line | **K**ill |
| ⌃T | Swap the characters on either side of the cursor | **T**ranspose |
| ⌃O | Insert a new line after the cursor, without moving the cursor | **O**pen line |
| ⌃L | Center the cursor line in the view | Re**l**ocate view |
| ⌃V | Move down one page | Page down |
⌃K and ⌃Y work together. ⌃K removes text to a private "kill buffer". ⌃Y pastes it back ("yank"). This buffer is separate from the clipboard that ⌘C and ⌘V use. Many apps support ⌃Y, but not all of them do.
Comparing with arrow-key shortcuts
The two families overlap. Choose by habit and by where your hands already are.
| Task | Arrow-key way | Control-key way |
|---|---|---|
| Go to start of line | ⌘← | ⌃A |
| Go to end of line | ⌘→ | ⌃E |
| Delete to end of line | ⇧⌘→ then ⌫ | ⌃K |
| Delete the next character | fn⌫ | ⌃D |
⌃K is the clearest gain. It does in one keystroke what takes two or more with the arrow keys.
A worked example
Suppose you typed this line in a Notes document and want to fix it:
Send the reprot to Dana by Friday, thanks for your help yesterday- Click anywhere in the line, then press ⌃A to jump to the start.
- Press ⌃F repeatedly (or ⌥→ to jump by word) until the cursor sits between the "o" and "r" of "reprot".
- Press ⌃F once more so the cursor sits between "r" and "o". The transposed pair is now on each side of the cursor.
- Press ⌃T. The letters swap and the word reads "report".
- Press ⌃E to jump to the end of the line. Press ⌃B a few times to back up, then use ⌃K to delete the rest of the line from the cursor onward.
Pressing ⌃Y afterward restores the deleted text, which gives you a cheap undo for that one deletion.
Common problems
- Nothing happens in a code editor or terminal. Some apps define their own keys. In Terminal, ⌃A and ⌃E work through the shell and ⌃K deletes to end of line there too. In editors such as VS Code, a setting or an extension can change them.
- ⌃V does not page down. Some apps map ⌃V to something else. Use fn↓ or the Page Down key instead.
- ⌃Space opens something else. That shortcut is not part of the Emacs set. By default it switches input sources, and it is configured in System Settings, covered in a later chapter.
- You pressed ⌘ instead of ⌃. ⌘A selects all text. ⌃A moves the cursor. Check which key you are holding.
Practice
Open TextEdit, type three or four lines, and move around using only ⌃A, ⌃E, ⌃N, ⌃P, ⌃F, and ⌃B. Then delete lines using ⌃K. Do this for a few minutes a day, and the keys become automatic quickly.
Exercise
The cursor is in the middle of a line, and you want to delete everything from the cursor to the end of the line using only the keyboard and the fewest keystrokes. Which shortcut do you press, and what can you press afterward to bring the text back?
Show answer
Press ⌃K to delete from the cursor to the end of the line. Press ⌃Y to paste the deleted text back, in apps that support the kill buffer.
Exercise
You typed "teh" and the cursor sits right after the "h". Which single shortcut fixes it? Hint: you may first need to move the cursor to the right spot.
Show answer
With the cursor between "e" and "h", press ⌃T to swap the two characters on either side. This gives "the". If the cursor is after the "h", ⌃T in most Mac text fields swaps the last two characters before it, which also gives "the".