:.,$d
This will delete all content from current line to end of the file. This is very useful when you're dealing with test vector generation or stripping.
Go to the first line from which you would like to delete, and press the keys dG
Just add another way , in normal mode , type ctrl+v
then G
, select the rest, then D
, I don't think it is effective , you should do like @Ed Guiness, head -n 20 > filename in linux.
Source: Stackoverflow.com