POSTS
How to Delete All Lines in Vim
Reading time: 1 min
Written by Marco Tschannett
Deleting all files of a document is not a very common use case. Needlessly it has to be done sometimes.
Disclaimer: This is part of my vim commands “repo”. I use this posts to archive solutions for text editiong problems I faced while using vim. To listen all shortcuts look here.
Problem
I want to delete all lines of my currently opened file. Nothing should be saved.
Solution
gg
- Move cursor to first line.dG
- Delete everything from current position to the last line of the file
To summarize this commands: We move the cursor to the first line of the current document. After that we tell VIM that we want to delete everything to the last line of the document.