> I want to count all ; present at the beginning of a line.
>
> ;;;sentence; => should give 3 and not 4
> ;;sentence; => should give 2 and not 4
> ;sentence; => should give 1 and not 4
Then depending on what you want to do with that count (put it at
the beginning of each line, or print it for one line), the two I
gave should work:
>> :%s/^;*/\=strlen(0).' '.submatch(0)
>>
>> which will count just the ";" at the beginning of the line and
>> put that count there. If you need the count in a variable
>> instead of on the line, you could do something like
>>
>> :echo strlen(matchstr(getline('.'), '^;*'))
-tim
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---