Re: Count character in line
- Klaus Bosau wrote:
> Hi,:help 'report'
> I'd like to find out how often a certain character shows up in a line.
> To achieve this I tried
> fun! s:N()
> return substitute(v:statusmsg, '^\(.\).*', '\1', '')
> but this didn't work. Obviously v:statusmsg sometimes isn't set. How can
> I ensure v:statusmsg is set? Or maybe there's another solution too...
e +/Count $VIMRUNTIME/macros/matchit.vim
HTH --Benj Fisher
- On Wed, 1 Jan 2003, Benji Fisher wrote:
> :help 'report'Thanks a lot! I turned it in
> e +/Count $VIMRUNTIME/macros/matchit.vim
return substitute(v:statusmsg, '^\(.\).*', '\1', '')
but this seems to work properly only if typed by hand. When put in a
function body v:statusmsg still is not set reliably. The 'matchit'
solution turned out to be quite similiar to the solution I already
found, but due to that this seems to become a bit slow with large
strings I'd actually prefer a working solution based on :s. I wished I'd
know why v:statusmsg isn't set always...
- On Wed, 1 Jan 2003, Antoine J. Mechelynck wrote:
> you might set it yourself, e.g.Hi,
> let v:statusmsg = ""
> .s/ etc.
and thanks! I already tried this, but obviously it sometimes isn't set
by :s. I don't know why...