IT Questions and Answers :)

Sunday, August 25, 2019

How do you delete 4 lines using the "vi" Unix editor?

How do you delete 4 lines using the "vi" Unix editor?

  • y4
  • 4<delete-key>
  • 4x
  • 4dd 

EXPLANATION

I am using putty and vi editor if select 5 lines using mouse and i want to delete those lines how can i do that
Forget the mouse. To remove 5 lines, either:

  • Go to the first line and type d5d (dd deletes one line, d5d deletes 5 lines) ~or~
  • Type Shift-v to enter linewise selection mode, then move the cursor down using j (yes, use h, j, k and l to move left, down, up, right respectively, that's much more efficient than using the arrows) and type d to delete the selection.
Also how can i select the lines from keyboard like in windows i pres shift and move the arrows to select the text. how can i do that in vi
As I said, either use Shift-v to enter linewise selection mode or v to enter characterwise selection mode or Ctrl-v to enter blockwise selection mode. Then move with h, j, k and l.
I suggest spending some time with the VIM Tutor (run vimtutor) to get more familiar with VIM in a very didactic way.

See also

 

Share:

0 comments:

Post a Comment

Popular Posts