Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align columns in VI

Tags:

vim

vi

I have a bunch of lines that I'd like to split into two columns, and get the data from each column. The data looks something like this:

current_well.well_number
current_well.well_name
current_well.well_type_code
well_location.section
well_location.range

Essentially what I'd like to do is split the line based off of the period, turn the data into two columns, and then grab the data for each column. I know this can be done in Excel, but I'm really interested in VIs solution for this problem. I know that

%s/\./

will format the string with empty spaces. But once I have the data looking like:

current_well    well_number
current_well    well_name
current_well    well_type_code
well_location   section
well_location   range

How do I grab all the values for each column so I can paste it into another application?

like image 801
Blake Blackwell Avatar asked Apr 24 '09 19:04

Blake Blackwell


1 Answers

The linux column command works well for creating the columns

:%!column -s . -t

Then use block copy.

like image 143
MES Avatar answered Oct 11 '22 01:10

MES