Sublime Forum

Isolate and Step Through Multiple Cursors

#1

On a regular basis I find that while using multiple cursors I can type 90% of what I want with all the cursors and then I have to iterate over each of the lines adding in what differs between the lines.

For instance (an extremely contrived example using prose not code, but the example should illustrate the point), suppose we wanted to type something like:
“John likes to [Activity], he finds it very enjoyable.”
Every line follows this trend, and all we want to do is type all of these lines and insert on each line a particular activity:

“John likes to braid his dog’s hair, he finds it very enjoyable.”
“John likes to eat marshmallows, he finds it very enjoyable.”
“John likes to cry himself to sleep, he finds it very enjoyable.”
“John likes to throw rocks as far as he can, he finds it very enjoyable.”

As of right now if you wanted to do something like this you have a few choices, the first is to type out everything excluding the activity:
“John likes to , he finds it very enjoyable.”
And then you can add in each of the activities, this involves a bunch of cursor maneuvering, either you are selecting with the mouse or tapping the arrow keys, this approach is a bit artificial since we have to ignore and return.
Another attempt would be to type out
"John likes to "
And then fill in the actions and then finish up by setting up again the multiple cursors, this is workable, but once again it diminishes the strength of multiple cursors which is practical parallelization.

So I suggest that multiple-cursors can be isolated allowing you to utilize a single instance of a set multiple cursors at a time, effectively allowing you to temporarily serialize your actions while using multiple cursors.
Something simple like alt-space could shift you into isolating the first cursor (by line number), and then you could use the arrow keys to move between the different cursors, then either alt-space again or escape or clicking off the multiple cursors would return you to your standard selection mode (or with clicking off return you to a single cursor as it currently does).

The usage for this would be as follows, assuming we want to do the example above we would create multiple cursors for each of the lines we intend to write:

|
|
|
|

Then we would type the first part - "John likes to " - Leaving us with:

John likes to |
John likes to |
John likes to |
John likes to |

We would then hit alt-space, which would focus us in on the first cursor (|| for focused cursor):

John likes to ||
John likes to |
John likes to |
John likes to |

We would then type “braid his dog’s hair”, down-arrow, “eat marshmallows”, down-arrow, “cry himself to sleep”, down-arrow, “throw rocks as far as he can”, leaving us with:

John likes to braid his dog’s hair|
John likes to eat marshmallows|
John likes to cry himself to sleep|
John likes to throw rocks as far as he can||

Hitting alt-space again (or escape) returns us to using all of the multiple cursors at once again:

John likes to braid his dog’s hair|
John likes to eat marshmallows|
John likes to cry himself to sleep|
John likes to throw rocks as far as he can|
(No particular cursor is selected, in this example we change || -> |, could bold or change the focused cursor in the program)

Then we can finish up by typing “, he finds it very enjoyable.”, which will leave us with the following:

John likes to braid his dog’s hair, he finds it very enjoyable.|
John likes to eat marshmallows, he finds it very enjoyable.|
John likes to cry himself to sleep, he finds it very enjoyable.|
John likes to throw rocks as far as he can, he finds it very enjoyable.|

Which as per standard, you can thing either click or hit escape to remove the multiple cursors, leaving you with your desired result.

I think this would be an excellent addition to Sublime Text, multiple cursors have thoroughly enriched my experience, and any application where I can’t use multiple cursors feels that much worse of an experience, its a wonderful tool, yet, I think it has room to improve and this type of augmentation would make the use of multiple cursors grow from being extremely useful 80% of the time (20% of the time you’re forced to fiddle with your cursors to get them to work the way you want, such as in the example above) to being absolutely the correct tool to use for 98% of cases where you need to edit multiple lines.

Some nice benefits of this change would be that you could even isolate to a single cursor and then change only one or two lines of a selection before returning to using all of the cursors (for instance maybe instead of “John likes to” you wanted to change one of the lines to read just “John loves”, you could do this by isolating the cursor of the line you wanted to edit and then deleting the “likes to” from the line and replacing it with “loves”, and then perhaps on another line you change the “likes to” to “hates” as in “John hates not being able to use multiple cursors, it absolutely infuriates him”.

0 Likes

#2

You mean like this :wink::

This is part of MultiEditUtils and called “selection fields”.

5 Likes

#3

Gasp! Precisely like that!

Thanks for the link, that’ll do just fine :smiley:

0 Likes