On Jul 22, 2011, at 1:26 PM, Eric Weir wrote:


On Jul 22, 2011, at 9:32 AM, Tony Berkopes wrote:

As the wc.vim script states it is 'Strunk & White' compliant as to the EXACT number of words in a manuscript or other documents that must have an exact count. There IS a difference to the word count between the wc.vim and the other examples. I also have not determined which of the 2 is faster. Any comments from other readers is WELCOME!!

If you have read the code in wc.vim, I commented out the part that counts until a series of '--------' 8 dashes is found. I don't want/ need that and it probably slows it down for no reason.

Just copy/paste the example in a previous post into your .vimrc and add the example to your status line.

Thanks, Tony.

A little unclear what you're suggesting, though. When you speak of commenting out lines in wc.vim, it sounds like you're proposing retention of it for word count functionality.

When you speak of copying and pasting "the example in a previous post" into my .vimrc, it sounds like you're recommending replacing wc.vim with your script.

Or are you suggesting putting the wc.vim code in my .vimrc and incorporating the code for getting the count into the status line into it?

Is your script Strunk and White compliant?

Also, what is the command to run it?

Regards,
------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA  USA
eew...@bellsouth.net




--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

E,

In wc.vim there is a section of code that reads:

let n = wc_start_line
    while n <= wc_end_line
        let line = getline(n)
"         if match(line, "^--------") >= 0
"             let stop = " until '-------- found'"
"             break
"         endif
        let c = JCWC_line(line)
        let wc_count = wc_count + c
        let n = n + 1
    endwhile


the part commented OUT will read until it finds -------- OR 8 dashed lines in your file. These lines allow you to find the word count of just a part of the file, maybe a paragraph or 2. I don't need that and it probably slows things
down so I commented it out in wc.vim.

cut/paste this code to your .vimrc:

let g:word_count="<???>"
function! WordCount()
     return g:word_count
endfunction

function! UpdateWordCount()
     let s = system("wc -w ".expand("%p"))
     let parts = split(s, ' ')
     if len(parts) > 1
         let g:word_count = parts[0]
     endif
endfunction

augroup WordCounter
     au! CursorHold * call UpdateWordCount()
     au! CursorHoldI * call UpdateWordCount()
augroup END

ADD THIS to your statusline setting:

set statusline+=[wc:%{WordCount}]

OR

nmap <leader>wc :echo 'wc:'WordCount()

then :so .vimrc<CR> -- this will reload .vimrc so the code will work.

the first pass will display <???> until it does the counting of each word. ON a large file, like eval.txt (help file) it may take a second or 2. I have NOT timed the above code vs wc.vim. On the help file, wc.vim was slow but the output was 46k+ words, I have NOT tried the above code on the same file.


--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to