Selon monax <[email protected]>:

> Hello.
>
> How I can change this code
>
> a = 10
> bb = 100
> ccc = 1000
> d = 10000
>
> to this
>
> a   = 10
> bb  = 100
> ccc = 1000
> d   = 10000

There might be simpler ways to do that, but this works:

function! Equalize () range
        let a:r   = range(a:firstline, a:lastline)
        let a:max = 0
        for l in a:r
                call setline(l, substitute(getline(l), "\\s*=", "=", ""))
                let a:i = stridx(getline(l), "=")
                let a:max = a:i > a:max ? a:i : a:max
        endfor
        for l in a:r
                let a:i = stridx(getline(l), "=")
                let a:s = ""
                for n in range(a:i, a:max)
                        let a:s = a:s . " "
                endfor
                call setline(l, substitute(getline(l), "=", a:s . "=", ""))
        endfor
endfunction

You can then call the function as: :'<,'>call Equalize() (with the range
automatic in visual mode).

Best,
Paul

-- 
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

Reply via email to