Robots & Pencils
RoboPress
Published in
3 min readJun 8, 2018

--

Every year at WWDC, Apple announces a new version of Xcode, complete with new features meant to make building the latest and greatest apps for their platforms easier.

As soon as we could, we got our hands on the beta version to give some of these new features a try, starting with multi-cursor editing, which allows the user to edit multiple lines of text simultaneously in Xcode.

How to use it

You can access multi-cursor mode by holding down the Ctrl & Shift keys and left-clicking in your source file. An additional cursor will appear on screen for each left-click performed. From there, any key you hit will perform that action for every cursor, including highlighting text.

Xcode will remember all of your cursors as you move between files, so if you navigate back to a file that was in multi-cursor mode, all cursors will be right where you left off.

When you are finished with multi-cursor mode, simply press escape to return to regular editing mode for the current file. Other files in multi-cursor mode will remain in multi-cursor mode until you exit.

There is one quirk to be aware of with highlighting while in multi-cursor mode. When two highlights overlap, they merge into one, and the middle cursor is discarded. To prevent this from happening, you need to pay close attention as you are selecting with the keyboard.

Potential use cases

  • Easily change more then one declared property of a class or struct from a let to a var(and vise-versa).
  • Quickly refactor the name of a local variable or type name within a function, closure or class declaration.
  • Add attributes to multiple functions such as @discardableResult or @objc.

Conclusion

The multi-cursor mode feature is easy to use, but keep in mind that there are no flashy controls to prompt you to use it. You need to select the Ctrl & Shift keys and left-click in your source file to access it. Once you’ve used it a few times, it should become more natural.

--

--

A digital innovation firm. We help our clients use mobile, web & frontier technologies to transform their businesses and create what’s next.