📢 Actions Speak Louder Than Words!

VIM - Delete every lines

Posted: Jul 18, 2020 | Reading time: 2 min
⚠️ Warning: This post is over a year old, the information may be out of date.
📢 I’ve moved to a new website. Please visit me at https://journal.robbi.my !
post

It been awhile since my last project (warehouse stock system) in Korea almost 1 years ago, I have been idle because no projects comes in.

Lot of self learning, administration, attend training and etc to kill the time. So this means, I have free time to learn something advance with VIM.

Maybe some of you don’t know what is vim. In short this is text editor on your terminal (unix-terminal) and capable to do lot of thing if you know how to use.

In this episode, I want to share how I deleting every lines on current existing file via vim and it works for me ( Thank to Alvin Alexander for tips). To delete all lines in vim, insert this command:

:1,$d

This vim “delete all lines” command can be read like this:

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” After typing the command, you need to hit the [enter] key, and when you do so, all lines in the file will be deleted.

Well i just re-post the same thing from Alvin Alexander. All creadit goes to him.

For your information, I have 3 trick how to wipe up all lines inside text file. One is what i share above and the other 2 techniques is using pressing gg and then dG but it not always for for every version of vim editor. The last one is nullify the file using cat /dev/null > target_file but this command is dangerous if mistake happen, it much better to use first technique so I will open, view and confirm what inside my text file and nuke it…bomb!.. remove all lines!!!

Edit

Have some thoughts, discussion or feedback on this post?
IndieWeb Interactions

Below you can find the interactions that this page has had using Indieweb. Which means, you can mentioned this URL on any website that support WebMention. Have you written a response to this post? Let me know the URL:

((Do you use a website that do not set up with WebMention capabilities? You can use Comment Parade.)