Natan Yellin
Natan Yellin

Reputation: 6387

Delete lines backwards

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.

Upvotes: 12

Views: 3713

Answers (3)

Xavier T.
Xavier T.

Reputation: 42228

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.)

Upvotes: 2

Waseem
Waseem

Reputation: 8402

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

Upvotes: 1

cnicutar
cnicutar

Reputation: 182639

Did you try something like d10k ?

Upvotes: 22

Related Questions