Tuesday, December 15, 2009

Re: Counting ; character

Hi epanda!

On Di, 15 Dez 2009, epanda wrote:

> Yes you've seen my cursor pos Christian.
> Is it faster than my func ?

Interesting challenge ;) I changed your function a little bitđ and made
a test:

com! Count :call CountCharBeforeCursor(';')
com! Count1 :let a=len(split(getline('.')[0:col('.')-1], ';'))
com! Count2 :let a=strlen(substitute(getline('.')[:col('.')-1], '[^;]', '', 'g'))

Now using timing.vimē on this line (cursor on first of the 2 consecutive
;;):
;foo1;foo2;foo;;bar

Let's see:


for i in ['Count', 'Count1', 'Count2'] | exe "TIME 100 ".i | endfor
Execution took 0.094060 sec. (count=100)
Execution took 0.007555 sec. (count=100)
Execution took 0.009596 sec. (count=100)


đ)I changed your function to save and restore cursor position.
ē)http://www.vim.org/scripts/script.php?script_id=1530


regards,
Christian
--
hundred-and-one symptoms of being an internet addict:
22. You've already visited all the links at Yahoo and you're halfway through
Lycos.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: