On Tuesday, December 20, 2011 5:53:00 AM UTC+9, Дмитрий Франк wrote:
>
> Your suggestion 
>
> len(iconv(getline('.'),  &encoding, 'char'))   
>
> returns length of current line, but i need to get length of all lines from 
> buffer start to current line. line2byte('.') does this.
> To workaround with this, i have to write cycle for each line. Imagine how 
> long this cycle on Vimscript will work on large buffers.
>
>
  len(iconv(join(getline(1, line('$')), "\n"), &encoding, "char")) 

Or if you want to treat large file.

  let s = 0
  for i in range(1, line('$'))
    let s += iconv(getline(i)."\n", &encoding, "char")
  endfor

Note that you may get different result if you want to treat DOS format.



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

Raspunde prin e-mail lui