Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to delete all lines of file in Vim

📅 2011-Apr-18 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ delete, vim ⬩ 📚 Archive


To delete all the lines of a file that is open in Vim.


Deleting all the lines of a file is not a frequently used operation. So, I need a command that is easy to recall, even though it is not used much. I find dG easy to remember since I frequently use dd to delete a line, and also gg and G, which move the cursor to the first and last line of the file respectively.

Tried with: Vim 7.3

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧