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