Delete all lines in Vi/VIM editor “Vi clear file” Linux/Unix

Many people facing an issue and some error when they opening Vim editor or Vi editors. So also you are one who facing the same errors so this is so simple to fix this type of error and use Vim editor or Vi editors easily.

So it’s easy to fix but many people are new they don’t know about this error how to fix this small error. So this is easy to delete all lines from a file you already open the file.

Delete all lines in Vi_VIM editor “Vi clear file” Linux_Unix

Follow our steps to empty a file. this step is so simple.

Simply go to a command file editor and then press the ESC button & then press gg two times. So after doing this you will go to the first line of the page So then press the dg button from your keyword after implementing this command from the first line to the last line all of your files will clear.

So this is simple to delete command or empty the editor, So also another alternative method is available if you want to apply this method so simply apply this command Vi/Vim. Simply visit the command page and run this command.

cat /dev/null > file


Keep in mind both are diffirent commands. i mean this command is two.

So I hope this article is helpful for you, we explain you how to fix error, delete or clear all lines while when you are using Vim/Vi editor. So if you still facing any issue please drop a comment below we try our best to solve your problem.

Notify of
Inline Feedbacks
View all comments