Damien Romito
Damien Romito

Reputation: 10065

How edit multiple lines on Xcode (shortcut)

I'm sorry, I don't find an already asked question for this problem...

in Xcode, what is the shortcut to edit multiples lines like the "CMD+click" of sublime text?

enter image description here

Upvotes: 79

Views: 27038

Answers (5)

Daniel Klöck
Daniel Klöck

Reputation: 21137

It is possible with Xcode 10+, see the wwdc2018 presentation of the functionality.

Ways to create multiple cursors:

  • ⇧ Shift + ⌃ Control + Left Mouse Click: Will create a new cursor on every click
  • ⇧ Shift + ⌃ Control + : Will create a new cursor above
  • ⇧ Shift + ⌃ Control + : Will create a new cursor bellow
  • ⌥ Option + drag: Will create a new cursor on every line you drag

preview:

enter image description here

For more information, see this answer

Upvotes: 136

Gpx
Gpx

Reputation: 33

Select the line you want to edit, then press option + command for a moment demo

Upvotes: 3

Zack
Zack

Reputation: 1

I had this same question a few weeks ago, if you use the Option Key you can use column select and edit multiple lines like in your picture. Where the confusion comes in is it is used for multiple things. If you click the option key over a variable or text it shows a question mark and shows information about what you click on. However, if you hold the option key while before the line or not over text it shows up as a plus symbol and you can drag and select multiple lines and edit them at the same time.

Upvotes: 0

RoyR
RoyR

Reputation: 179

Multiline editing is supported in Xcode 10, Ctrl + Shift + click the lines you want to edit.

Upvotes: 10

Jace Tan
Jace Tan

Reputation: 363

I'm not sure how helpful this is to you, but if you want to change a variable name, you can click it, hover over it until the triangle dropdown button appears, click it and select Edit All in Scope.

This allows you to change all instances of that variable name.

enter image description here

Upvotes: 12

Related Questions