How can I clean up misaligned columns in text?

前端 未结 6 665
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-31 09:08

I have a C program that outputs two columns, utterly misaligned. The reason for the misalignment is lengths of words in the first column are very different.

I have an o

6条回答
  •  梦如初夏
    2021-01-31 10:00

    If you want to do the processing in Vim (as opposed to fixing the generator), install the superb align plugin and run the following:

    ggVG
    \tsp
    

    The first command breaks down to gg (go to the start of the file), V (enter visual line mode), G (go to the end of the file). As a combination, it visually-selects the entire file. \tsp is an Align map that aligns on white-space.

    If you prefer to do things at the : command line, you can use an alternative separator (e.g. ###) and use the command-line Align:

    :%s/\s\+/###/g
    :%Align ###
    :%s/### //g
    

    It's longer, but you may find it more logical/memorable.

提交回复
热议问题