Quote:
Originally Posted by kovidgoyal
You will be able to do this (and much more powerful things) using the upcoming function mode for search and replace which will allow you to write arbitrary functions that will be called for each match during search and replace. So you would insert
<!-- chapter # -->
in the text and then use
<!-- chapter # -->
as the search expression and the following simple function as the replace expression.
Code:
class ChapterNumbering(object):
def __init__(self):
self.number = 0
def __call__(self, match):
self.number += 1
return str(self.number)
function = ChapterNumbering()
Then when you are ready to have your numbers generated, just run a bulk search and replace on all files and all the comments will be replaced by the chapter number.
And if you want to insert the chapter number after the comment instead of replacing the comment, you can do that as well, with a slight modification to the function.
Note that I haven't finished designing the function mode, so some details int he above may change.
|
This is just too awesome!