Sunday, April 29, 2018 [Tweets] [Favorites]

Multiple Cursors in Xcode

Daniel Martín:

For the new refactoring engine, the Xcode team developed a simple implementation for testing, but kept it disabled:

defaults write com.apple.dt.Xcode PegasusMultipleCursorsEnabled -bool true

Press Command and click/select some text and the editor will create a new cursor.

Any edits that you make are then repeated by all the cursors simultaneously. This can make certain batch changes faster and more reliable than doing them one-by-one, and for many common cases it’s easier (and requires less of a mental context switch) than writing a regular expression or script. The Xcode implementation is difficult to use in practice, though, because when Command is down, Xcode often wants to do something with the word I’m clicking on/near, rather than letting me place the cursor. Also, the edits are not bundled into undo groups the way you would expect.

Update (2018-06-04): Ole Begemann on Xcode 10:

“The Xcode Source Editor now supports multi-cursor editing allowing you to quickly edit multiple ranges of code at once.

Place additional cursors via ⌃+⇧+Click or with column select (⌥+Click+Drag), or using ⌃+⇧+Up/Down.”

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment