Word Counting in Org Mode

If you do your writing in Org mode and like to maintain a running word count—especially useful for professional writers and students assigned an n word paper—Angelo Basile has a nice tip on how to install a word count function to your org buffers.

I temporally installed and enabled wc-mode for this post to see how it works and it seems like an excellent solution if you're looking for something to keep track of your word count. The exact format of the display is customizable (of course) but the default seems reasonable. Here's the defcustom from wc-mode.el:

(defcustom wc-modeline-format "WC[%W%w/%tw]"
  "The format string for the modeline.
The detailed information for this minor mode can be shown in many
ways in the modeline. The formatting strings recognized in this
format are as follows.

  %W  Original word count (before changes)
  %L  Original line count
  %C  Original character count
  %w  Change in words
  %l  Change in lines
  %c  Change in characters
  %gc Character change goal
  %gl Line change goal
  %gw Word change goal
  %tw Total words in buffer
  %tl Total lines in buffer
  %tc Total characters in buffer

The default modeline, WC[%W%w/%tw], will display the original number
of words followed by the change in words (delta), followed by the total
number of words in the buffer.
It will looks something like WC[742+360/1100] in the modeline.

As you can see, the display is very flexible and can display just about any word-count-type information you want. If you don't want the word count in every Org buffer, don't include the add-hook in your configuration and just call wc-mode when you to turn it on.

UPDATE [2017-05-03 Wed 12:21]: Fixed link.

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

    Here's some code that I use. It doesn't count words in Org headings, and it acts on either the current region or the current subtree. An improvement that could be made would be to ignore Org drawers and keywords, but it's still pretty good. :)

    (defun my/count-words-in-subtree-or-region ()
    ;; Bind this to a key in org-mode, e.g. C-=
    (call-interactively (if (region-active-p)

    (defun my/count-words-in-subtree ()
    "Count words in current node and child nodes, excluding heading text."
    (message "%s words in subtree"
    (-sum (org-map-entries
    (lambda ()
    (forward-line 1)
    (while (or (looking-at org-keyword-time-regexp)
    (forward-line 1))
    (count-words (point)
    nil 'tree)))))

  • Win Treese

    Thanks for the post in the archives. A very minor note: he link to Basile's post has an extra trailing / that doesn't quite to his page.

    • jcs

      Fixed. Thanks.

  • Daniele Nicolodi

    The link is broken again. Basile's blog seems abandoned.

    • jcs

      That's what I'm seeing too. I went to his site and looked through the blog archives but I didn't see the post.