Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-cursor editing in Xcode 10

What is 'Multi-cursor editing' in Xcode 10 editor. (more information about the same is mentioned in release notes but unable to understand.)

How exactly does it work?

like image 235
Krunal Avatar asked Jun 05 '18 09:06

Krunal


People also ask

How do you edit multiple cursors?

A common way to add more cursors is with Shift+Alt+Down or Shift+Alt+Up that insert cursors below or above. Note: Your graphics card driver (for example NVIDIA) might overwrite these default shortcuts. Ctrl+D selects the word at the cursor, or the next occurrence of the current selection.

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

To edit multiple instances of text within different sections of a document, you can use multi-cursor editing. This allows multiple cursors to be placed in different spots so text can be added, modified, or deleted.

its the name of Source Editor, for reference purpose I taken the answer from whats-new-in-xcode10 and Sample link 1 and Sample link 2

The Xcode 10 Source Editor now supports multi-cursor editing allowing you to quickly edit multiple ranges of code at once.

  • shift + control + click
  • shift + control +
  • shift + control +
  • option + drag

With a source control-enabled project the source editor displays changes made by a developer in the gutter and shows changes made by other developers that haven’t yet been pulled into the project

like image 83
Anbu.Karthik Avatar answered Sep 20 '22 10:09

Anbu.Karthik


The best way to use it is by using the Select Next Occurrence command from the Find menu.

Its default keyboard shortcut is alt + cmd + e, but you could set it to cmd + d to mimic Sublime Text's behavior.

This way, you can edit code lines that are different, whereas the solutions in the other answers only allow you to edit similar lines.

For example, if you have this code:

NSString *myStringg = @"stringg"; // print the stringg NSLog(@"Here is my stringg: %@", myStringg); 

you simply:

  1. manually select the first Stringg occurrence from the first line using the cursor
  2. hit the Select Next Occurrence's keyboard shortcut 4 times
  3. hit the right arrow key
  4. hit backspace

and you'll have:

NSString *myString = @"string"; // print the string NSLog(@"Here is my string: %@", myString); 
like image 22
Iulian Onofrei Avatar answered Sep 21 '22 10:09

Iulian Onofrei