Wednesday, November 23, 2011

Re: Character count in current paragraph

On Thu, November 24, 2011 5:56 am, Ben Schmidt wrote:
> Hi, guys!
>
> Looking for some Vim voodoo a little bit outside my areas of expertise!
>
> I'd like to put the number of characters in the current paragraph (i.e.
> area
> between empty lines) in my ruler, or have it displayed when I press a key
> (either
> will do). That will save me having to exit normal mode and do vipg<C-g>
> and then
> scan the status line for the relevant count every time I'm interested in
> it. I'm
> editing 7-bit text, so number of bytes would be just as good.
>
> I'm in a bit of a hurry and would just love it if one of you could chuck
> me an
> answer that I can copy and paste!

I think either of those two will work:
:'{,'}s/./&/gn
or even:
:echo eval(join(map(getline("'{", "'}"),
\ 'len(split(v:val, ''\zs''))'), '+'))

Those two won't include the line-ending bytes when counting (as g<C-G>
does. If you need this, you can possibly also map something using the
line2byte() function:
:echo line2byte(line("'}")) - line2byte(line("'{")+1)

regards,
Christian

regards,
Christian

--
You received this message from the "vim_use" 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

No comments: