Reputation: 111
I have code like:
Name,
Age,
Country,
Continent,
I want to align it like this using VIM.
Name ,
Age ,
Country ,
Continent ,
How to do this?
Upvotes: 0
Views: 68
Reputation: 11810
Using external command "column":
:%! column -t -s, -o,
-s .............. separator
-o .............. output separator
Upvotes: 0
Reputation: 196566
Assuming your buffer only contains those lines…
Substitute each trailing comma with some large number of spaces:
:%s/,/ /
Move the cursor where you want your column of commas to be:
ell
Enter visual-block mode and extend the selection to the top line:
<C-v>gg
Extend the selection to the end of the line:
$
Change each line of the block to a comma:
c,<Esc>
Upvotes: 1