luni, 1 noiembrie 2010

Replace with appereance number

Using Jedit, at replace can be put a BeanShell snippet.
If you have a file with:

And want to be like:

(eg: a file with same error message in many places and you want to uniquely identify them)

Then in Jedit do:
- in search field enter: a
- change the option to use BeanShell instead of text
- enter in replace field: i=1
- press replace all
- click on main window press undo
- back, in replace field put: _0+i++
(_0 is the searched string ; + is for unification of the strings, i++ increases the value of i by 1)
- press replace all

The every appearance of the searched text is replaced with the text and the number of appearance.

Niciun comentariu:

Trimiteți un comentariu