To delete everything in a file with Vim, use this command.

ggdG

explain

  • gg go to the first line
  • dG delete to the last line of file (G is movement which is " go to the last line of the document ")

You can also apply this grammar by replacing d with something else. For example

  • gg=G auto format file
  • gggUG make all text in file upper case.
  • ggVG select all text in file