Last Updated: December 26, 2018
·
749
· mattboehm

Column formatting in vim

On a linux box, say you have text like this:

name age occupation
bob 22 programmer
nathaniel 111 painter
jo 14 student

Visually select the lines in vim and type !column -t

You should now see:

name       age  occupation
bob        22   programmer
nathaniel  111  painter
jo         14   student

4 Responses
Add your response

I prefer using Tabular gem.

over 1 year ago ·

Although I use tabular for this kind of things, it is a nice use of shell features from vim. Thanks :)

over 1 year ago ·

Tabular's awesome if you plan on doing this a lot, but I figured this was a good example of using bash filters, and may come in handy if you don't have tabular installed on whatever box you're on.

over 1 year ago ·

if you have variable assignments like foo=bar you can also align those by simply using

:'<,'>s/=/ = /

before the !column -t
call

over 1 year ago ·