Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 533
Damien Romito Avatar asked Mar 31 '15 15:03

Damien Romito


People also ask

How do you edit multiple lines at once?

Select the lines you want and then press: Windows: Shift + Alt + i. Mac: shift + option + i.

How do I use multiple cursors in Xcode?

If you want to add multiple cursors at the same column, instead of wasting time aiming and clicking, you can use the arrow key to navigate. Hold ⌃ – Control and ⇧ - SHIFT then ↑ or ↓ to add cursors to the line above and below your current position. You can deselect a cursor by hit the arrow in the opposite direction.

How do I highlight multiple items in Xcode?

Hold down the Shift and Control keys, and double-click the second topAnchor in the second line to select it at the same time as the existing selection. So far, this is just like what we did before. Now: press the Left-Arrow key.


2 Answers

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

like image 51
Daniel Avatar answered Sep 21 '22 03:09

Daniel


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

like image 40
Jace Tan Avatar answered Sep 23 '22 03:09

Jace Tan