How to columnize text with tabs (in vim or on the shell)

shelltext-editorsvim

I have a frequent need to manually manipulate tab-delimited text for data entry and other purposes. When I do this, it helps if the text is aligned properly into columns. For example (assuming 4-space tabs):

# original format
abcdefghijklmnop    field2
abcdefgh    field2
abcdefghijkl    field2

# ideal format
abcdefghijklmnop    field2
abcdefgh            field2
abcdefghijkl        field2

I am very familiar with using the column utility to columnize text this way, but the problem is that it uses spaces to align the columns, and I specifically need tabs. This requirement also appears to rule out the Tabularize plug-in.

Is there any way that I can columnize text with tabs specifically, either within vim or at the shell? It looks like I might be able to do it with groff/tbl, but honestly I'd rather columnize it by hand than mess with that….

Best Answer

The csv.vim - A Filetype plugin for csv files also supports tab-delimited files, and has :ArrangeColumn and :UnArrangeColumn commands for that.

Related Question