Auto enumeration with search-replace (something like \# in Emacs)
Submitted by Friday, 14 March, 2008 - 17:44
on
Hi,
I've been looking for a feature in Jedit, but couldn't find it so far. Emacs allows a special regular expression in replacement strings: \# This gives the current match number/index, i.e. 0 if this is the first match, 1 if second, 2 if third, etc... You can also add an integer to that to start enumeration at any number. So with this, you can automatically enumerate things pretty easily. That is, you can convert
cat
dog
lion
monkey
elephant
into
1 cat
2 dog
3 lion
4 monkey
5 elephant
with a single search-replace operation using \#
Is this possible with jEdit either with regular expressions or with a beanshell script? If so, how?
Thanks in advance.
I've been looking for a feature in Jedit, but couldn't find it so far. Emacs allows a special regular expression in replacement strings: \# This gives the current match number/index, i.e. 0 if this is the first match, 1 if second, 2 if third, etc... You can also add an integer to that to start enumeration at any number. So with this, you can automatically enumerate things pretty easily. That is, you can convert
cat
dog
lion
monkey
elephant
into
1 cat
2 dog
3 lion
4 monkey
5 elephant
with a single search-replace operation using \#
Is this possible with jEdit either with regular expressions or with a beanshell script? If so, how?
Thanks in advance.