Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to type different value for multiple cursors?

When doing multi cursor selection, often you need to type a different value for each, you've to cancel selection even though all cursors are where you want them to be.

Is it possible to activate some sort of mode and press tab to automatically iterate through each one by one on every tab and type your value. Esc to cancel the mode.

enter image description here

Note: how in end I had to type 1, 2, 3, 4 manually. Those could have been food categories, clothing size, select options etc.

like image 993
Muhammad Umer Avatar asked Sep 05 '25 20:09

Muhammad Umer


2 Answers

In case you don't want to install extension, you can copy sample data (which is generated by your favorite scripts or tools, for example) then paste it to the current cursors.

For example, I generate numbers by

JavaScript:

Array(10).fill(0).map((a, i) => i + 1).join('\n')

Or shell / bash script:

seq 10

Then,

enter image description here

like image 105
Ninh Pham Avatar answered Sep 09 '25 00:09

Ninh Pham


For the special case of when you want to insert values that follow a sequence at your multiple cursor locations, then the powerful Insert Nums package for Sublime Text can help.

Insert Nums can fill in numbered blanks (1,2,3,4, ... 10), and much more. Just about anything you could write as a for loop can be generated and inserted at the multiple cursors. This includes integer/float/string, count up/down, arbitrary start/stop/step values, and formatting to hex, binary, etc., representation. You can also evaluate an expression at each index, so for example you can create a geometric or power series or a pattern of bit shifts.

The default case for Insert Nums is integers, starting at 1, incrementing by 1, and ending when all selections are filled. For the example problem in the question of numbering Items, all you'd have to do is Ctrl+Alt+N, then Return. The numbers 1 through 5 would be filled in.

like image 29
jskroch Avatar answered Sep 09 '25 00:09

jskroch