Created
May 15, 2013 13:32
-
-
Save kmlawson/5584008 to your computer and use it in GitHub Desktop.
Vimscript for a live word count. Mixed match code from stackoverflow and added check for empty file: http://stackoverflow.com/questions/114431/fast-word-count-function-in-vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! WC() | |
if getline(1) != '' | |
if &modified || !exists("b:wordcount") | |
let l:old_status = v:statusmsg | |
let position = getpos(".") | |
execute "silent normal g\<c-g>" | |
let b:wordcount = str2nr(split(v:statusmsg)[11]) | |
let v:statusmsg = l:old_status | |
call setpos('.', position) | |
return b:wordcount | |
else | |
return b:wordcount | |
endif | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment