//View Tip #835
» Making shell scripts executable via editor hooks
» Making vim oneliners
apt_get
Similar Tips
» Sudo from vim to write file» Making shell scripts executable via editor hooks
» Making vim oneliners

Latest tips by RSS
Click here to subscribe

Follow Shell-Fu on Twitter
Click here to follow

Follow Shell-Fu on identi.ca
Click here to follow
A few quick ways to empty a file of text in vi (all of these are done in command mode):
:1,$d -- :1[enter]dG -- ggdG
Comments
Add your comment
Comments are currently disabled
#1
ggdG I like tihs one
Posted 2009-06-11 12:03:13
I like Jackie's, but here's another way:
cat /dev/null > file
cat /dev/null > file
Posted 2009-06-11 16:45:52
Technically, the last one ggdG is a vim thing, and in pure old vi you have to do 1GdG.
But if you are not in vi, then clearing the file with >file is fastest.
But if you are not in vi, then clearing the file with >file is fastest.
Posted 2009-06-12 15:39:38