Created
September 10, 2013 07:11
-
-
Save mhinz/6505968 to your computer and use it in GitHub Desktop.
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! s:count_characters(bang) range abort | |
let nchars = 0 | |
let lines = a:bang ? range(1, line('$')) : range(a:firstline, a:lastline) | |
for line in lines | |
let nchars += strlen(getline(line)) | |
endfor | |
if a:bang | |
echomsg '>>> The file contains '. nchars .' characters.' | |
else | |
echomsg '>>> Lines '. a:firstline .' to '. a:lastline .' contain '. nchars .' characters.' | |
endif | |
endfunction | |
command -range -bang -bar Count <line1>,<line2>call s:count_characters(<bang>0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment