I know that I can delete until the first character with dgg or until line 1 with d1 Shift-G.

But I would prefer something conceptually elegant if possible.

I guess I can easily just remap a single key to d2 Shift-G, but I’m still not clear on how you find or decide what key to map to, in case you overwrite something important.

Is there any syntax of Vim native built-ins which possibly says:

“Delete until the line one beneath the first”.

For example, maybe there is something I could add between d and gg which says “+1” wherever you are going?

Or is there a special code like gg but for the second line?

Thank you

2 Answers 2


I think what you are looking for is the following command:


The 2,. is the range on which d is applied it goes from the second line to the current line (.)

And you can map that to whatever you want:

nnoremap <leader>d :2,.d<CR>
  • Thanks, that’s pretty good. But why is it so common to map to commands with the leader key? Why not just map to a key by itself? Thank you Mar 3, 2022 at 15:32
  • 1
    Well you said I’m still not clear on how you find or decide what key to map to, in case you overwrite something important. and I think that's exactly the reason why you should use mappings with the leader key. My personal rule of thumb is never override a built-in feature, only create mapping which don't already exists and <leader> help a lot to do that.
    – statox
    Mar 3, 2022 at 16:05

When I delete large amount of lines, I generally prefer to first do a selection and then delete the selection.

So first I start the selection and would go to the top of the file: vgg

Then I'd move to the first line I want to delete with arrow keys.

Finally, I'd hit either d or D to delete what is selected, or all the lines selected.

If I were to need to do that many times, I'd create a macro

qa<type your sequence of commands>q

To then apply the macro you do:


You can repeat the last macro you used with:


As for which keys to remap, I don't use many remapped commands, but I have them on my F2 to F12 keys. Those are not used by vim anyway. For example, to write the signature in a Debian changelog file, I use F5:

map <F5> 0C -- Alexis Wilke <[email protected]>  <C-R>=strftime("%a, %d %b %Y %H:%M:%S %z")<CR><Esc>

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.