Reputation: 3515
I often have to insert sequences like
:1, :2, :3, :4, :5
into a plain text file. That's easy to do with 5 items like in my example but it becomes tedious if I have something like 42 items. Is there a possibility that I only type the colon and have it repeated a number of times on the same line?
I can do the numbering using an extension so it would be nice if multiple cursors would be placed after the inserted colons immediately.
Upvotes: 0
Views: 654
Reputation: 28673
You can use the extension Regex Text Generator. You write a Regular Expression that generates your needed text
Type the following in the Generate Box
(:{{=j[0]+1}}, ){10}
You are left with the ,
at the end
To place the multiple cursors:
Find in Selection
: Alt+L:
Upvotes: 1
Reputation: 181339
See Is there a way to insert N times the same characters for some options on inserting repeated text.
Using the HyperSnips approach this snippet in your plaintext.hsnips
file will do what you want:
snippet `:\*(\d+)=` "expand" A
``
let howMany = parseInt(m[1]);
let start = 1;
let newStr = '';
for (let index = 0; index < howMany; index++) {
newStr += `:${start++}, `;
}
rv=`${newStr.slice(0,-2)}`
``
endsnippet
Since it is just javascript, you can make that snippet as generic as you want.
Upvotes: 1