|
|
|
|
|
by arp242
1045 days ago
|
|
> Isn't there a plugin to just display word count in the corner somewhere automatically? You can add it to your statusline (or tabline, ruler) with the wordcount() function: :let &statusline ..= ' words: %{wordcount().words}'
---Aside: that "one-liner" doesn't "count the words in the file" at all? It just replaces all words with "1" and echos the last line number. I'm confused because this seems so wrong that I may be missing something? Unless the "67 substitutions on 5 lines" message is intended as the "word count", in which case I submit that 1) this is the ugliest thing I've ever seen, and 2) the author of this article doesn't know Vim all that well (there are so many better/easier ways to do this). |
|
Others have commented on built-in vim functionality for counting words, but assuming the author copy-pasted a similar looking command, they may have intended something like:
Knowing that the n flag will return a count instead of doing the substitute may be useful to know, but I personally don't need a search count very often.Knowing that you can execute a vimscript expression on each search match using \= is also cool and I was unaware of such functionality. https://vimhelp.org/change.txt.html#sub-replace-expression