Cut first column from file in Vi(Vim)

I have a parts file that looks like this:

EE36264|0NH46||Y|A|EA|0|0|0|N|LUNETTE 3" ADJ. EYE|0|0|*|0|PEOZZU|N|12|N|N|VPS|N|N|N|N|LUNETTE 3" ADJ. EYE|0|||Receive into Inventory|81755|EE36264|*|*|*|0|0||EE36264|A|*|*
F1.5|53932||Y|A|EA|0|0|0|N|FLAT ZERO CAL BLOCK|0|0|*|0|PEOZZU|N|12|N|N|VPS|N|N|N|N|FLAT ZERO CAL BLOCK|0|||Receive into Inventory|81755|F1.5|*|*|*|0|0||F1.5|A|*|*
F7-412-1|55723||AB|A|EA|0|0|0|N|SWITCH|1|0|*|0|PAOZZN|N|12|N|N|VPS|N|N|N|N|SWITCH|.3|||Receive into Inventory|81755|F7-412-1|*|*|*|1|0||2GFV00605-0005|A|*|*
FCO26A|55719||Y|A|EA|0|0|0|N|CRWFT 3/8DRX13/16|0|0|*|0|PEOZZU|N|12|N|N|VPS|N|N|N|N|CRWFT 3/8DRX13/16|0|||Receive into Inventory|81755|FCO26A|*|*|*|0|0||FCO26A|A|*|*
M1363400104|0NH46||Y|A|EA|0|0|0|N|DRAIN HOSE|0|0|*|0|PEOZZU|N|12|N|N|VPS|N|N|N|N|DRAIN HOSE|0|||Receive into Inventory|81755|M1363400104|*|*|*|0|0||M1363400104|A|*|*
M1490300004|0NH46||AB|A|EA|0|0|0|N|RUBBER SEAL|0|0|*|0|PEOZZU|N|12|N|N|VPS|N|N|N|N|RUBBER SEAL|0|||Receive into Inventory|81755|M1490300004|*|*|*|0|0||M1490300004|A|*|*
CA2210A4R|13002||Y|A|EA|0|0|0|N|WASH CAPTIVE L\BOLT|0|0|*|0|XBOZZN|N|12|N|N|VPS|N|N|N|N|WASH CAPTIVE L\BOLT|0|||Receive into Inventory|81755|CA2210A4R|*|*|*|0|0||CA2210A-4R|A|*|*
CL-4-BLPL-0.75-S|99862||Y|A|EA|0|0|0|N|L HANDLE, 1/4|0|0|*|0|PEOZZU|N|12|N|N|VPS|N|N|N|N|L HANDLE, 1/4|0|||Receive into Inventory|81755|CL-4-BLPL-0.75-S|*|*|*|0|0||CL-4-BLPL-0.75-S|A|*|*

It is an ascii text file ( *.csv ) that can go on for 1000s of lines.  I want to cut out the first column , the part number only.  It is delimited by a split bar "|".

Can I do this in Vi ( Vim) so I produce a file of the first column only like below?

EE36264
F1.5
F7-412-1
FCO26A
M1363400104
M1490300004
CA2210A4R
CL-4-BLPL-0.75-S

thanks.

are you looking for vi solution only?

for alternate:

awk -F"|" '{ print $1 }'  filename > NewFilename
:1,$ s/|.*//
:w output_file

Worked! Thank you very much.

Yes. I need a Vim solution because I am using Vim on Windows 7.

awk, cut, sed and so on can't be run on a windows box , right?

:slight_smile:

You can install cygwin and there you can use mentioned commands.