Increase counter
-
Hi,
I have some report scripts, where I occasionally need to make some adjustments. E.g., in-between rows 5 and 6 I want to insert a new row, therefore all rows >= 6 would need to have the counter increased by one.
R1=Blank,CustomHeaderStyle:font-weight:bold,CustomHeader:Phase 1,Style:background-color:#B2CBB6,NoSuppress R2=Blank,CustomHeaderStyle:font-style:Italic;font-weight:bold,CustomHeader:Deadline: WD2 EOD,Style:background-color:#B2CBB6,NoSuppress R3=A#ValidSup1004,Cell_Link4 R4=A#ValidSup1005,Cell_Link5 R5=A#ValidSup1014,Cell_Link14 --> new row R6 inserted R6=A#ValidSup1015,Cell_Link15 (after insert should be R7) R7=A#ValidSup1016,Cell_Link16 (...R8) R8=A#ValidSup1017,Cell_Link17 (...R9) R9=A#ValidSup1018,Cell_Link18 (and so on) R10=A#ValidSup1024,Cell_Link24 R11=A#ValidSup1025,Cell_Link25 R12=A#ValidSup1026,Cell_Link26 R13=A#ValidSup1027,Cell_Link27 R14=A#ValidSup1028,Cell_Link27
Is this possible to achieve via RegEx or any other option?
Thanks,
Daniel -
Hi @Daniel-Holzmann ,
if your scripts always follow the same or similar structure as the one you posted, one option could be (create a backup of your files first!):
1- Insert your Rxx= row wherever is needed.
2- Use a ‘regex replace’ with the expression^R\d*=
and leave empty the field ‘Replace with’ (and Replace All)
3- With your cursor at the beginning of the first line , use the ‘Column editor’ Alt+C, select the option ‘Number to start’ and set the Initial number as 1 and Increase by 1.
4- Again, with the cursor at the beginning of the file, open the Column Editor and this time use ‘Text to Insert’ with the character R.And I think that should do it.
-
Alternatively, we have a whole FAQ on doing mathematical search-and-replace (assuming you are willing to use a plugin)
-
@PeterJones said in Increase counter:
assuming you are willing to use a plugin
…AND take the leap into programming, if you’re not already a coder. (OK, it might be some light programming, if you copy+paste+change one of the provided examples).
-
Thanks guys. I will go with litos81’s proposal which is working perfectly fine for what I need.
The plug-in version I’d have considered for private purposes, but installing plug-ins on my work PC is always a big challenge for our IT department.