How do you delete all text above a certain line

vim
user339108 picture user339108 · Nov 12, 2010 · Viewed 178.6k times · Source

How do you delete all text above a certain line. For deletion below a line I use "d shift g"

Answer

Andy White picture Andy White · Nov 12, 2010
dgg

will delete everything from your current line to the top of the file.

d is the deletion command, and gg is a movement command that says go to the top of the file, so when used together, it means delete from my current position to the top of the file.

Also

dG

will delete all lines at or below the current one