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.
Asked
Active
Viewed 3,328 times
11

Natan Yellin
- 6,063
- 5
- 38
- 57
3 Answers
21
Did you try something like d10k
?

cnicutar
- 178,505
- 25
- 365
- 392
-
1This is the vim way. With the relativenumber feature this is very easy too ;) – lucapette Aug 24 '11 at 12:48
-
1In my vim both of these delete the line that I am on, not what the questioner asked for. – ACRL Aug 24 '11 at 19:31
-
@ACRL: `d9k` delete exactly the same lines as `10k10dd` does. Just use `kd9k` to keep the current line. – ib. Aug 25 '11 at 01:15
-
@ib, your comment should really be an answer – Natan Yellin Aug 26 '11 at 00:29
2
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.)

Xavier T.
- 40,509
- 10
- 68
- 97
1
You could select the lines that you want to delete in visual
mode and then d
elete those.

Waseem
- 8,232
- 9
- 43
- 54
-
-
1Maybe you are right. But in visual mode I do not have to count the number of lines upto where to delete. That method is prone to errors. – Waseem Aug 24 '11 at 12:55
-
Did not think about that, because I only thought about the situation where you know the amount of lines to delete. – Nobody moving away from SE Aug 24 '11 at 13:02
-
Not a problem :). See http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118 also. – Waseem Aug 24 '11 at 13:17
-
Counting lines is easy if you have line numbers turned on and relative line numbers enabled. – ACRL Aug 24 '11 at 19:33
-
Visual mode still works with known line counts: `V9kd` and you can adjust up and down before hitting `d`. – Walf Jul 21 '16 at 02:13