On Tue, October 20, 2009 9:46 am, Christian Brabandt wrote:
> fu! MaxLen()
> return strlen(max(map(getline(1,"$"), 'matchstr(v:val, "^\\d\\+")')))
> endfu
Even better and imho more robust should be
fu! MaxLen()
return max(map(getline(1,"$"), 'strlen(matchstr(v:val, "^\\d\\+")')))
endfu
Otherwise, if you have long numbers in the first column, max() will always
return the wrong result, since its argument seems to overflow (max
argument seems to be 2^31).
> PS: Anybody knows why map(getline(1,"$"), 'matchstr(v:val, "^\\d\\+")')
> worked, but not map(getline(1,"$"), "matchstr(v:val, '^\d\+')"), which
> would have the benefit of not having to double escape the regular
> expression, thus looking clearer?
Thanks John, I think that explains it.
regards,
Christian
--
:wq
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---