How to transpose the contents of lines and columns in a file in Vim?

前端 未结 6 655
既然无缘
既然无缘 2021-02-02 16:49

I know I can use Awk, but I am on a Windows box, and I am making a function for others that may not have Awk. I also know I can write a C program, but I would love not to have s

6条回答
  •  面向向阳花
    2021-02-02 17:43

    Charles Duffy's code could be shortened/improved using izip_longest instead of izip:

    function! Rotate()
        :py import vim, itertools
        :py vim.current.buffer[:] = [''.join(c) for c in itertools.izip_longest(*vim.current.buffer, fillvalue=" ")]
    endfunction
    

提交回复
热议问题