max_len = max(len(n) for n in vim.current.buffer)
vim.current.buffer[:] = [''.join(n) for n in zip(*(n + ' ' * (
    max_len - len(n)) for n in vim.current.buffer))]
EOF
endfunction
Can I transpose a file in Vim?