Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Accidentally I managed to copy-paste a paragraph in vim a zillion times. How do I select and then delete the text from my current position to the end of file?

In Windows, this would be Ctrl-Shift-End, followed by Delete.

share|improve this question
up vote 26 down vote accepted

Enter visual mode, go to end of file, delete.

Alternatively, you can do:


To delete from the current position to the beginning of the file.

share|improve this answer
Ugh, I'll never remember all these vim shortcuts. The Windows shortcuts are just so much more intuitive. – ripper234 May 27 '11 at 14:45
Personally, I find vim's to be more intuitive. V, enter visual mode G, almost like "go", to the end of the file. And x, remove. – Mark Szymanski May 27 '11 at 14:46
@ripper234: don't try to remember "snippets" to do specific tasks, focus on the subcommands. That's part of the magic of vim: using these smaller commands to build up larger, more complex things. It's almost infinitely flexible. – Reid May 28 '11 at 16:38
And it really helps a lot to take the time and read through the related vim-help-sections with :h command-you-need-help-for – Gjallar Jan 26 '12 at 8:09
To add to this: run vimtutor from the commandline to get familiar with them @ripper234 – Bernhard Jun 13 '12 at 22:32

d is delete and G moves to the end of the file, so dG will delete to the end of the file. It includes the entire current line though; if you're mid-line and want to preserve everything before the current position you need to use Mark's method

share|improve this answer

Yet another method: :.,$d

That means in ex mode, address current line to end, and delete.

share|improve this answer

You could also just type u to undo the changes that resulted in the errant copy-paste.

share|improve this answer
not always possible, see the "select". Imagine you have written some code at the end of the file (and want it somewhere else), dG allows you insertion with p|P – relascope Dec 30 '15 at 18:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.