Wednesday, December 3, 2014

editing tab separated files

Consider the following file

rajulocal@hogwarts:~/x$ sed 's/\t/,/g' data.txt
___ Maria (coffee liquer),Tia,Tia Maria is a coffee liqueur made
originally in Jamaica using Jamaican coffee
beans.,http://en.wikipedia.org/wiki/Tia_maria
Mississippi port,Natchez,A city located on the Mississippi river in
Mississippi,http://en.wikipedia.org/wiki/Natchez,_Mississippi

This file has two rows each containing 4 fields. The fields are tab
delimited. But since gmail does not allow to display tab characters, I
converted them to ',' for illustration purposes.

Also, I am using two lines for illustrating purposes. But the actual
file is pretty big.

One characteristic of this file is that field 3 usually occupies way
more characters than fields 1, 2 and 4.

Now when I view the file in vim, I can set :tabstop, :shiftwidth to a
very large number so as to line up the fields. But this in turn makes
file very "wide".

Is it possible to set different field widths for different columns of the file?
For example, here I'd like to have 25 chars width for fields 1,2 and
fields 3,4 to occupy 50 chars and wrap the remaining text within that
cell.

Is that doable in vim or should I use a spreadsheet program (ex:-
oocalc) instead?

raju
--
Kamaraju S Kusumanchi
http://malayamaarutham.blogspot.com/

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: