Thursday, November 24, 2011

Re: Character count in current paragraph

On 11/24/11 03:12, Ben Schmidt wrote:
>> :echo line2byte(line("'}")) - line2byte(line("'{")+1)
>
> I'm using the last one, as I like the linebreaks counted (at
> least for now) as they will be turned into spaces when the
> lines are joined (which is what will happen before they are
> pasted into a textbox with a character limit!). I'm sure the
> second last one could easily squeeze in a +1 to count the
> linebreaks, too, though.

You can also tweak the first one to use "\_." to "replace"
linebreaks. With the /n flag, it doesn't actually do the
replacement, just yield the count, so it can be written as

:'{,'}s/\_.//gn

(adjusting the range accordingly)

-tim


--
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: