How to delete columns in vi file?
Solution 1
Press ctrl+v
for block selection. use h, j, k, l
keys to navigate and press key d
to delete the selected block. The graphical editor like kate
also having capability of the block selection.
Solution 2
If you are not confined to vi, shell command is a good choice for this task.
cat your_filename | cut -f 1,5 > result_filename
About rectangle selection in vim, you must guarantee that the field in all lines with the same width.
Perhaps vim command
:%!cut -f1,5
is OK too, but I can not give it a try now.
Jarhead
Updated on July 09, 2022Comments
-
Jarhead almost 2 years
I have a vi file containing hundreds of lines with the following format
029.inp.log: SCF Done: E(RHF) = -844.790844670 A.U. after 26 cycles
I want to delete all of the columns (separated by spaces/tabs. got messed up when I pasted it here) other than the first (029.inp.log:) and the fifth (-844.790844670). Can anyone help me?