Reputation: 1348
How to do that in vim, lets say im in line 100 and i want to delete 20 lines upward? how to do that in vim linux?
Upvotes: 3
Views: 420
Reputation: 114138
You can do it relative if you know the number of lines:
d20k
Or absolute if you know the line number:
d80G
d
= delete, 20k
= 20 lines up, 80G
= goto line 80
Or without taking you current position into account:
:80,100d
Personally, I use visual mode a lot becuase it gives me a nice feedback:
Upvotes: 7
Reputation: 6258
In normal mode you can use d
and the movenment key k
to delete upwards. And then you prefix that command with the number of times you want to repeat the command like 100dk
.
If you just want to delete to the beginning you can use gg
along with d
, gg
sends the cursor to the first character in the file. So ggd
will delete the first line to the line you are standing on.
Upvotes: 5
Reputation: 3560
You can do it upwards with the range.
:-20,.d
In this you can specify the range of line to delete it .
Will deletes 20 lines upwards to the current and this is kind of an ex-mode command.
Upvotes: 3