vim demo - moving and deleting lines

Question 1:
Open the file test.txt and move line 9 to line 5.

Answer:

vi test.txt
Switch to line mode and go to line 9:
:9
press Enter – you are on line 9. Cut this line – press:
dd
Switch to line mode again and go to line 5:
:5
Press Enter – you are on line 5. To paste cutted line to line 5 press Shift+P – paste above this line, so the current line becomes line 6 and pasted line – becomes line 5.
Save and quit from line mode:
:wq!
And press Enter

Question 2:
Open file test.txt again and delete first 3 lines.

Answer:
vi test.txt
there is a possibility that you’ll be on line 5 – per previous operation. Press:
gg
to get to the line 1.
Press:
d3d
to delete first 3 lines.
Save and quit from line mode:
:wq!
And press Enter