Word Diff Counter

Chris Maiorana has an interesting take on counting words. He’s a writer and like all writers, he’s interested in how many words he’s written in the current session. His reasons for wanting that count boils down to it providing a measure of his daily work and, perhaps more important, helping him to know when to stop.

But, he says, there are some problems with word counts as usually implemented. The most important concerns the way that many (the majority of?) writers work. They like to reread and edit what they wrote in their last session. That means that words may be subtracted as well as added. What’s really needed, he says, is a count of the number of words that have changed.

His solution for that is to use git diff to find out how the text has changed and count the number of changes. It’s a bit fussy as you’d imagine but really pretty straightforward. Take a look at his blog post for the code and details.

I love this idea but I’m not sure it’s for me. For long form writing, what I’m mainly interested in is progress so knowing my current word count—regardless of additions or subtractions—is what’s important to me. For short form writing, such as this blog, I really care only about the total word count since I almost always complete a post in a single session—not counting a final editing pass just before I publish it—and I’m never in any danger of burning out while writing a single post.

Still, if you’re a writer and interested in measuring your work rather than your progress, Maiorana’s hack may be just what you’re looking for. You’ll need to keep your text in Git but you should be doing that anyway.

This entry was posted in General and tagged . Bookmark the permalink.