Follow the below steps to delete all the lines in a file (emptying file) using VI / VIM editor.
- Open the file
gg, this will move the cursor to the first line of the file.
- Now press
dG, this deletes all the lines.
- Finally, type
:wqto save the changes and exit from the file.