thanks a lot, I get the final version.
function InsertNumber(start, end,...) " step, radix(d,o,x), is_padding
	let l:i = a:start
	let l:curr_line = 0
    let l:step = get(a:000,0,1)
    "echo l:step
    if l:step <= 0
        echo "Error: step cannot <= 0."
        return -1 
    endif
    let l:radix = get(a:000,1,'d')
    "echo l:radix
    if a:0 == 3
        let l:is_padding = 0
    else
        let l:is_padding = 1 "default padding
    endif
    if l:radix == "o"
        "let l:width = strlen(printf('%o',a:end))
        let l:width = len(a:end)
        let l:format = '%0'.l:width.'o'
    elseif l:radix == "x"
         "let l:width = strlen(printf('%x',a:end))
        let l:width = len(a:end)
        let l:format = '%0'.l:width.'x'
    else
        "let l:width = float2nr(trunc(log10(a:end))) + 1
        "let l:width = strlen(printf('%d',a:end))
        let l:width = len(a:end)
        let l:format = '%0'.l:width.'d'
    endif
    
    while l:i <= a:end
        if l:is_padding == 1
    		call append(l:curr_line, printf(l:format, l:i))
        else
            call append(l:curr_line, l:i)
        endif
        let l:i += l:step
    	let l:curr_line += 1
    endwhile
endfunction
-- 
-- 
You received this message from the "vim_use" 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
--- 
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sunday, July 17, 2016
Subscribe to:
Post Comments (Atom)
 
No comments:
Post a Comment