Today I Learned

hashrocket A Hashrocket project

Delete All Lines with Vim

I have a Vim pane I've been filling with throwaway code lately, and wanted to find the most efficient way to wipe it clean from inside Vim:

This is an option I've seen on message boards:

:1,$d

At seven keystrokes, it's pretty good. This is what I've been doing with five keystrokes:

ggdG

Starting on the first line (Vim's default) would make the gg redundant, bringing it down to three keystrokes. That might be the lower limit to how concise this can be, though I'd be glad to see someone do it with less.

See More #vim TILs
Every developer at Hashrocket is a Vim expert. Check out our development environment, Dotmatrix, and if you are in Chicago, come to the Vim Chicago Meetup hosted at our Chicago office.