How to delete all the lines of text files with vim
This is a quick snippet for anybody wanting to delete all the lines of code of a text file when editing it in the terminal using vim.
Usually in vim when you open a file and you have to delete lines of code, it can be done individually using the following - but what if you have a big file and want to delete all the lines of code this could take forever.
But with the below vim command you can actually delete all the lines of code in one go.
Here is a breakdown of what you are actually inputting with the command:
- The : character starts vim's last line mode
- The 1 means, starting at line 1
- The ,$ means, until the end of the file
- The d means, delete.
I hope this short snippet has been helpful.
Visitors also viewed these posts