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