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.

  • 4
    Vim has undo. Press u.
    – Kusalananda
    Jul 26, 2019 at 19:47

6 Answers 6


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

  • +1 The other way to preserve part of current line is D<enter>dG: D to delete to EOL, <enter> to move to next line, dG to delete to EOF.
    – Jim L.
    Jul 26, 2019 at 19:49

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.

  • 3
    Ugh, I'll never remember all these vim shortcuts. The Windows shortcuts are just so much more intuitive.
    – ripper234
    May 27, 2011 at 14:45
  • 2
    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. May 27, 2011 at 14:46
  • 13
    @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, 2011 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, 2012 at 8:09
  • 2
    To add to this: run vimtutor from the commandline to get familiar with them @ripper234
    – Bernhard
    Jun 13, 2012 at 22:32

Yet another method: :.,$d

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


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

  • 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, 2015 at 18:49

works fine for multi line selection(in this case paragraph), but if you want to select within one single line it acts mysteriously(selects from cursor till beginning of the line).

In case of selection within Single line you have to use:


Which enters to Visual mode("v") and goes to end of line("$") and deletes("x") from current position until end of line.


Vggx didn't work for me, but vG$d did. vG$ selects to EOF (last character of last line), then whatever command you want to executed.

=This approach (command after selection) seems to work better. Of course, I'm using Vim 8.1 on Windows 10, and a few years later.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .