I'm often editing files where i have to delete everything except the five first and the three last rows. I do that by moving to row six and type ":,.$-3 d". Is there any way accomplish the same using d and some kind of motion?
[num] is the destination line number. Any other movement command will also work rather than
G, of course.
To delete the first five and last three rows, assuming you've just opened the file and are on the first line, it would be:
d5G # delete from current position to line 5 G # jump to last line d2k # delete from current position to 2 lines up (3 lines total)
Edit: Just reread the question and saw I got your intentions backwards - you want to keep the first five/last three, not delete them. In that case, it's:
G # jump to last line 3k # up 3 lines d6G # delete from current position to line 6