How edit multiple lines on Xcode (shortcut)

XcodeEditShortcutMultiline

Xcode Problem Overview


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

Xcode Solutions


Solution 1 - Xcode

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

Solution 2 - Xcode

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

Solution 3 - Xcode

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

Solution 4 - Xcode

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

Solution 5 - Xcode

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDamien RomitoView Question on Stackoverflow
Solution 1 - XcodeDanielView Answer on Stackoverflow
Solution 2 - XcodeJace TanView Answer on Stackoverflow
Solution 3 - XcodeRoyRView Answer on Stackoverflow
Solution 4 - XcodeGpxView Answer on Stackoverflow
Solution 5 - XcodeZackView Answer on Stackoverflow