I want to count the words in my buffers, but for TeX files, for instance, a lot of words (e.g., commands) shouldn't be counted. I'm aware that there are scripts that do this specifically for LaTeX, but I find them pretty inconvenient and they don't even work that well.
On the other hand, whoever wrote the syntax files for TeX already did a great job at tagging which words should be counted: the words for which Spell is enabled. Besides, using a method like this would be useful for every filetype, potentially ignoring comments and so on. And if you want to ignore more words you could just change it in your after/syntax files.
I couldn't figure out a way to do it, though. So, any ideas on how I could count only the words for which Spell is enabled?
I think this method (:%s/\<\w\{-}\>//gn) of counting the words looks like a good start, but we'd have to skip some words depending on their highlighting group.
after/syntaxfile and I think it would work pretty well at this point. :) – dbmrq Sep 24 '16 at 18:39texcount(included with TeXLive etc.); just did a check and saw that it's the same one used by the vimtex plugin (which you mentioned above). – VanLaser Sep 25 '16 at 10:05texcountand came up with that. Then I thought "cool, I'll share this on reddit". I'm still curious about this approach, though. – dbmrq Sep 25 '16 at 15:58