Multiple file delete in VIM
To remove all content in a file using Vim, follow these quick methods:
๐ Method 1: Using Normal Mode
Press
Esc
to ensure you're in Normal Mode.Type this command:
gg dG
gg
โ Moves the cursor to the top of the file.dG
โ Deletes from the current line to the end of the file.
Or combine it into one command:
ggdG
โก Method 2: Using Command Mode
Press
Esc
to switch to Normal Mode.Type
:
to enter Command Mode, then:%d
:
โ Opens the command line.%
โ Refers to the entire file.d
โ Deletes the content.
๐พ Save Changes After Deletion:
wq
:wq
โ Save and exit.Or just
:x
for the same effect.
If you want to exit without saving:
q!
Let me know if it worked or if you need more help! ๐
ย