I have a pipe-delimited file I am working with in Vim, how can I eliminate columns using this? For example - deleting everything before the third pipe on every line of the file
Method 1
If your pipe delimited lines start at line #1, move the cursor to line #1,
and press Shift-o
(letter 'o') to add a blank line above your first line.
Make sure the cursor is in the new first line. Press
q a
to start to record your key stroke series into register 'a'. (q
- start to
record; a
- record to register 'a')
Press
j d 3 f | q
(j
- down; d
- delete; 3
- the 3rd pipe; f
- find; |
- pipe sign; q
-
finish recording)
Press
u
to undo the deletion.
Check how many lines are there all together, say, 1000.
Move the cursor back to the first line, then press
1000 @ a
(1000
- run the recorded key stroke series 1000 times; @
- run the recorded key
stroke series; a
- in register 'a')
You have achieved what you want.
Method 2
:%normal 0d3f|
Please read the help for normal
:h normal