Reputation: 1778
For example :
xx
test1
xx
xx
test1
xx
test1
test1
i use the regex search : test\d to grab those text1 and want to replace it with ok# . Sot make it to be like this :
xx
ok1
xx
xx
ok2
xx
ok3
ok4
How to generate that increment number ?
Upvotes: 1
Views: 1252
Reputation: 22791
The built in Arithmetic
command can do this sort of thing for you. The full specifics of how that command works can be found in "how to add different number at end of multi line edit?" if you'd like to know the various things you can do with the command and how it works.
For your case, the steps would be:
Find
and use the Find All
button to select all of the items that you would like to replace; you end up with multiple cursors in the bufferok
) which will replace all of the matches with that textArithmetic
command and run it. The default expression for the command is i + 1
, which will do you want, so you can just hit enter to select it and run the command. The preview under the command name shows you what is going to be inserted.
Upvotes: 3