Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete columns in vi file? [closed]

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?

like image 799
Jarhead Avatar asked Apr 27 '16 02:04

Jarhead


People also ask

How do I delete multiple columns in Vim?

Start visual-block by Ctrl+v . Select second column (e.g. by pressing: W , G ). Delete it by pressing d .

How do you delete a column in a file in Linux?

Use the colrm command to remove specified columns from a file. Input is taken from standard input. Output is sent to standard output. If the command is called with one parameter, the columns of each line from the specified column to the last column are removed.

How do I delete content in vi mode?

To delete one character, position the cursor over the character to be deleted and type x . The x command also deletes the space the character occupied—when a letter is removed from the middle of a word, the remaining letters will close up, leaving no gap. You can also delete blank spaces in a line with the x command.


1 Answers

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.

like image 129
shafeeq Avatar answered Jan 04 '23 04:01

shafeeq