Tag: Xcode

Multi-Cursor Editing in Xcode 10

Multiple selection support in Xcode 10 is amazing. In previous versions, you could hold down the Option key to select a column of text, but you couldn’t do much with it. In Xcode 10, typing in such a multi-selection finally does the right thing: your text goes into each selection, so you can update multiple places at once. This alone really speeds up editing. But until recently, I had missed that multi-selection support goes far deeper:

  • Shift-Control to add selection: Hold down Shift and Control while clicking or dragging to add a new selection. So if you need to make the same edit in multiple places, just select each one, then start typing and make all the edits at the same time.
  • Option-Command-E to add the next occurrence of the current selection: If you already have something selected that you were going to type over, use Option-Command-E as needed to add selections at other places where this occurs, and edit just once.
  • Move multiple selections: As you’re editing, use the arrow keys to move multiple selections in unison; use Option to move by words, use Control to move by subWordsLikeThis (you may need to turn off System Preferences > Keyboard > Shortcuts > Mission Control > Move left/right a space).
  • Copy/paste: Create multiple selections, Copy, set multiple insertion points, Paste. Works like magic.
  • Use Find to create selections: Look in the Find menu for more tools. For example, Select All Find Matches and Select Find Matches in Selection let you set up multiple selections based on your search text.

This can all be accomplished by other means, but multiple selections fit naturally with the way I work, and don’t require extra mental effort or a context shift. This feature has been invaluable in moving some code from C++ to Swift. Thanks to the Xcode team for getting this right.

Happy editing!