+36

Generate a sequence of numbers; increment replace

Chris Casey 13 years ago updated by Dhirendra Jaiswar 8 years ago 8
This is a regex feature that seems to be unique to TexPad on Windows. From their help files:

Expression: Effect: 
\i Replace with numbers starting from 1, incrementing by 1. 
\i(10) Replace with numbers starting from 10, incrementing by 1. 
\i(0,10) Replace with numbers starting from 0, incrementing by 10. 
\i(100,-10) Replace with numbers starting from 100, decrementing by -10. 


Examples:
To insert line numbers at the start of each line: 
Search for:^ 
Replace with:\i 
To update sequence numbers of the form Axxx, Bxxx, … ,Zxxx where "xxx" is any number >= 100, independent of the letters, which are to be preserved: 
Search for:\([A-Z]\)[1-9][0-9][0-9]+ 
Replace with:\1\i(100) 

That would be seriously cool. We're looking at migrating from TextPad to Sublime, and would love to retain this feature.
+3
I could write this functionality in a plugin but it would be better if it were implemented into the find & replace directly.
+2
Yes! This is one of the features I missed most moving from TextPad to TextMate. Now that I'm migrating to Sublime, I would love to have this back.
+2

 Similar functionality has been developed as a Sublime Text 2 Plugin. It is available via Package Control under the name InsertNums.


https://bitbucket.org/markstahler/insert-nums

+1

 We created a plugin with the functionality we needed.

https://github.com/eBookArchitects/Incrementor

+2

incrementing not working correctly. It is adding 10 to all the single digit incremented numbers like 110,210,310,410 etc., when used \1(10) and \1(100). I tried this in textpad. What is the correct replace string.

+1

Use curly bracket instead of parenthesis.

+3

Use curly bracket instead of parenthesis.