Is there any other possibility to delete from the current cursor position till end of the file without using the End keyboard key?

I know that I can perform it with d<CTRL-End> but perhaps is there an easier way.

Edit: dG doesn't help here as it deletes also the whole line the cursor is currently in. I don't want to delete anything on the left side of the cursor in the current line.

  • The dG command does exactly that. d is an operator for deletion, and G is a motion (it takes your cursor to the last line). If you don't want to save the deleted text to a buffer, its "_dG, if you feel you did any of this in error, hit the u key for undo.
    – user8919
    Commented Jun 27, 2023 at 20:37
  • 3
    @thinksinbinary dG deletes also the whole line the cursor is currently in. I don't want to delete anything on the left side to the cursor in the current line.
    – Rob Bar
    Commented Jun 27, 2023 at 21:13
  • Yes that is correct, i wasnt thinking about that, but i sure do like the dG command!
    – user8919
    Commented Jun 27, 2023 at 21:53
  • @BenVoigt: Thank you for the feedback - I've correct the title.
    – Rob Bar
    Commented Jul 1, 2023 at 11:12

4 Answers 4


With your cursor in starting position to begin, you can do: vG$d

  • v ( enter visual mode )
  • G ( go to bottom of file )
  • $ ( go to end of line )
  • d ( delete selection )
  • Thank you - it works!
    – Rob Bar
    Commented Jun 27, 2023 at 21:15
  • 1
    you can also use the c operator instead of d if you want to add something after where you wanted to delete, it will save you from having to enter insert mode.
    – user8919
    Commented Jun 27, 2023 at 21:57
  • NOTE: :set nostartofline makes the $ redundant, here, and is generally useful anyway.
    – romainl
    Commented Jun 28, 2023 at 13:16
  • @romainl That is incorrect. You still need the $ to move the cursor to the end of the line, otherwise you end up not deleting part of it.
    – 8bittree
    Commented Jun 28, 2023 at 14:05
  • 1
    @RobBar if this is the best answer to your question, consider accepting it with the V-shaped button to the left. Thank you.
    – Friedrich
    Commented Jul 3, 2023 at 8:36

Remastered original answer

Not the answer you are looking for but (unless we're playing Vim golf) I'd just type d$jdG or DjdG (as Izkata was kind enough to point out) and nothing fancy. That's deleting the rest of the line with d$ or D, going down one line with j and then deleting the rest of the buffer with dG.

This is a few more keystrokes but they come naturally to me, my fingers can stay on the home row for the most part and it's done before I even started to think if there's a shorter way to do it.

Anyways it's much faster than me playing hide and seek with End. Every manufacturer seems to have their own scheme of hiding this fine key. So I would definitely have to look down on my keyboard to locate it. Not worth it.

Bonus track

The caveat of above solution is that it's technically two deletions. It needs uu to undo, can't be repeated with . etc.

In comparison, using visual mode as per Zac's great answer we can undo with a single u but also not safely repeat. Using visual mode is better in this case but by no means perfect.

Seeing how d<C-End> solves exactly the problem and how awkward the End key is, you may consider remapping the motion to a key you can actually touch type. There does not seem to be a motion Z and z is at the end of the alphabet so I picked it:

:onoremap Z <C-End>

And dZ will behave exactly like d<C-End> and remove everything in the buffer starting from the cursor position. The whole family of cZ, yZ etc. will work.

This, you can undo with u and repeat with ..

  • 4
    d$ can instead be D
    – Izkata
    Commented Jun 28, 2023 at 14:10
  • 1
    @Izkata true. Maybe I'd type D... I honestly don't know :-) Definitely preferable from the home row point of view. I seem to like lowercase commands better for some reason.
    – Friedrich
    Commented Jun 28, 2023 at 14:35

I'm surprised no one has mentioned DjdG yet.

  • D deletes everything from the cursor to the end of the line.
  • j moves 1 line down
  • dG deletes all lines till end of file.

It's also fast to type, because all keys are on the home row.

  • 1
    I'm as surprised as you are.
    – Friedrich
    Commented Jun 29, 2023 at 12:44

I believe d<C-End> should do as you want.

Your problem with dG is that it is linewise (as I think can be gleaned from :help G); to force the motion to be character-wise, you could use v between the operator and motion. Similarly V would force linewise. So dvG almost works, but character-wise G ends up in column 1.

Fortunately, the <C-End> motion goes to the last character on the given line, which defaults to the last line. So it's a bit like G$ in one motion. Note that this is an "inclusive" motion, so you might want to do ld<C-End> if you want to keep the character under the cursor.

  • Almost. It does not seem to delete the last line of the buffer.
    – Friedrich
    Commented Jun 28, 2023 at 6:32
  • 1
    @Friedrich Oh, right, because G ends up in column 1. Hm.
    – D. Ben Knoble
    Commented Jun 28, 2023 at 12:45
  • I hate to point it out, but the question was how to do it without pressing the End key. The joke is that OP knew that <C-End> does exactly what he wants but he doesn't want to press that exact key.
    – Friedrich
    Commented Jun 30, 2023 at 6:09
  • @Friedrich oof. By the time we got through with dvG, I'd forgotten that. Oh well. I'll let the answer stand… vote away :)
    – D. Ben Knoble
    Commented Jun 30, 2023 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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