A simple minor mode to display output similar to that of the standard Unix wc command in the mode line: character count, word count, and line count. If there’s an active region, it displays that information for the region instead.

All this small “one-liner” package does is set the ‘mode-line-position’ variable appropriately:

    (setq mode-line-position
	  (6 (:eval (if (use-region-p)
			(format " %d,%d,%d"
				(abs (- (point) (mark)))
				(count-words-region (point) (mark))
				(abs (- (line-number-at-pos (point))
					(line-number-at-pos (mark)))))
		      (format " %d,%d,%d"
			      (- (point-max) (point-min))
			      (count-words-region (point-min) (point-max))
			      (line-number-at-pos (point-max))))))

and then define a trivial minor-mode to make it toggleable.

Please send bug reports and suggestions to toby-wc-mode@dr-qubit.org (you can post them here as well if you like, of course). I don’t check this page regularly, so anything not emailed to me is likely to languish here unnoticed for some time.

Note that other useful and very similar WordCount code is also available. But I had this code lying around, and it works well, so it might as well be made available.


CategoryDisplay CategoryModeLine CategoryModeLineConfiguration