Re: Re: Word count (continued)
- on 4/30/2003 11:46 AM Benji Fisher said the following:
> digitect@... wrote:You're right, I mis-understood one of my tests.
> > writing a function that *returns* the number of words, reduced
> > here:
> > let @/ = '\<\w\+\>' | let cnt=0 | g//let cnt=cnt+1 | echo cnt
> > except that this keeps returning the number of lines, not words.
> > If I change @/ to equal 'myword' it returns the correct count,
> > even if myword appears multiple times on the same line.
> I find that searching for 'myword' this way finds the number of
> lines containing 'myword', not the number of copies of 'myword'.
on 4/30/2003 12:23 PM Piet Delport said the following:
>I like it, thanks! (I had tried a parsing of redirection from
> What about:
> func WordCount()
> exec "sil norm! g\<C-G>"
> return matchstr(v:statusmsg, 'Word \d\+ of \zs\d\+')
'g/\<\w\+\>/s//&/g' but yours is many lines cleaner.)
Not exactly sure how '\zs' is working though, particularly the 's'.
Steve Hall [ digitect@... ]
Cream... the Vim text editor in sheep's clothing!