How edit multiple lines on Xcode (shortcut)
Asked Answered
B

5

75

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

Brakesman answered 31/3, 2015 at 15:15 Comment(6)
This would be a nice feature, but I don't think it is possible. Check Alcatraz packages maybe.Hussy
What exactly this command is for? For selecting multiple words/characters across multiple lines? If yes, you can achieve same in Xcode using "Option + Click".Pontine
oh? you probably changed something in the settings cause it's not works for meBrakesman
I was looking for this too but couldn't find a way. I ended up doing search and replace. In your example, I'd search for "self.player" and replace with "self.whateverPlayer"Vittoria
Hi @DamienRomito It's been a few years since you posted this. Any chance you happened to find a way to do this? ThanksPatriciapatrician
Sorry @Vladimir, still nothing...Brakesman
T
130

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

Transverse answered 18/9, 2018 at 8:25 Comment(2)
Do you know if there's a way to get the cursor in let's say every other line using keyboard only? (besides placing the cursor in many adjacent rows and then pressing enter).Infusible
I believe [shift] + [control] + left mouse click will be your best option. I don't know of any other way by k/b appart from the one that you described and that one is very unlikely to be useful.Transverse
U
12

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

Underlying answered 18/7, 2016 at 8:53 Comment(1)
In this case, the keyboard shortcut is ⌃⌘E ( control cmd + E ).Busiek
H
10

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

Healing answered 7/6, 2018 at 6:20 Comment(0)
D
3

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

Diversiform answered 25/4, 2019 at 9:42 Comment(0)
L
0

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.

Locoweed answered 24/6, 2018 at 23:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.