Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

4 Answers 4

up vote 16 down vote accepted
vGx

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

Alternatively, you can do:

vggx

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
7  
@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
1  
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

Your Answer

 
discard

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.