Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete lines backwards

Tags:

vim

vi

Is there a shortcut for 10k10dd? I want to delete the 10 lines prior to the cursor, without having to move the cursor backwards first.

like image 820
Natan Yellin Avatar asked Aug 24 '11 12:08

Natan Yellin


3 Answers

Did you try something like d10k ?

like image 147
cnicutar Avatar answered Sep 24 '22 06:09

cnicutar


In certain circumstances, those 10 lines are the beginning of a paragraph than you can delete with:

  • d{

or the beginning of a ( C-like) function

  • d[[

See :help object-motions for more details and ideas.

It is usually easier to use text objects than to count lines. ( Well on Vim latest versions, you can use set rnu to avoid manually counting backward or forward lines.)

like image 22
Xavier T. Avatar answered Sep 26 '22 06:09

Xavier T.


You could select the lines that you want to delete in visual mode and then delete those.

like image 29
Waseem Avatar answered Sep 25 '22 06:09

Waseem