Sublime Forum

ST3 increment by line?

#1

In sublimetext3 I need to replace all instances of

stream64 = Foo.GetStream64(path64);

Incrementing all the occurances of 64 per line like

stream64 = Foo.GetStream64(path64); stream65 = Foo.GetStream65(path65); stream66 = Foo.GetStream66(path66); ... stream1024 = Foo.GetStream1024(path1024);

without touching the other things, just the numbers. I don’t know much a bout regex so how could I make it?

0 Likes

#2

[quote=“Joscplan”]In sublimetext3 I need to replace all instances of

stream64 = Foo.GetStream64(path64);

Incrementing all the occurances of 64 per line like

stream64 = Foo.GetStream64(path64); stream65 = Foo.GetStream65(path65); stream66 = Foo.GetStream66(path66); ... stream1024 = Foo.GetStream1024(path1024);

without touching the other things, just the numbers. I don’t know much a bout regex so how could I make it?[/quote]

Regular expressions won’t help here. I’d just write a separate program to generate those lines. It’s only about four lines of code.

0 Likes

#3

[quote=“pete340”]

[quote=“Joscplan”]In sublimetext3 I need to replace all instances of

stream64 = Foo.GetStream64(path64);

Incrementing all the occurances of 64 per line like

stream64 = Foo.GetStream64(path64); stream65 = Foo.GetStream65(path65); stream66 = Foo.GetStream66(path66); ... stream1024 = Foo.GetStream1024(path1024);

without touching the other things, just the numbers. I don’t know much a bout regex so how could I make it?[/quote]

Regular expressions won’t help here. I’d just write a separate program to generate those lines. It’s only about four lines of code.[/quote]

How would it be and in what lang?

0 Likes

#4

[quote=“Joscplan”]

Regular expressions won’t help here. I’d just write a separate program to generate those lines. It’s only about four lines of code.

How would it be and in what lang?[/quote]

Whatever language you like. C++ fragment:

for (int i = 64; i < 1025; ++i) { std::cout << "stream" << i << " = Foo.GetStream" << i << "(path" << i << ");\n"; }

Run it from the command line and redirect the output to a file, then cut and paste.

0 Likes

#5

Use a plugin:
sublime.wbond.net/packages/Incr … 0Selection

Open the console and type this code to generate a sequence and paste in your code:

sublime.set_clipboard("\n".join(str(x) for x in range(64, 1025)))

Generate directly the final code:

sublime.set_clipboard("\n".join("stream%(pos)d = Foo.GetStream%(pos)d(path%(pos)d);"%{"pos":x} for x in range(64, 1025)))
0 Likes