striker wrote:
I have a large fixed width database file that I would like to delimit
with commas. For example here are 2 lines of the file:
210044012123540759F181012004103C 14 29847.3741091 4280 5070
42789 28529 2769 2449 3320
2948 05121
210044012112140906F091012004101J 2 11048.495609 5559 9973
5180 9974 5680 94572
5451 06148
length of field1 = 8
length of field2 = 2
length of field3 = 3 and so on through 35 fields.
I was going to use a simple regex replacement like: :%s/\(.\{8}\)\
(.\{2}\)\(.\{3}\)/\1,\2,\3,/g This does work when only replacing
a small number of fields. I get 2 errors when I source a file with
the command for all 35 fields. The errors are:
E51: Too many \(
E476: Invalid command
Two questions because of all of this:
1) What is the limit of \( that can be used?
2) Is there a better way of delimiting the file?
Using the vis.vim plugin (available from
http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs as "Visual
Block Commands"):
Position cursor, line 1, on a delimiting column.
ctrl-v$:B s/ /,/
Repeat with other columns.
Regards,
Chip Campbell