2

Stuck on the below problem where I need to delete lines 2-3, and then paste them before line 1 and after line 4 in 7 key presses or less

enter image description here

Keys available enter image description here

So far what I'm doing:

j
2dd
p
kk

which gets me to line 1 but then I'm on 7 key presses so I can't do a final P

Any ideas?

1 Answer 1

3

Took a few tries, but here's what you're looking for, based on my understanding of the problem:

jdjkPGP

Explanation:

  1. j - Go down one line (to line 2)
  2. dj - Delete the current line and the line below (lines 2 and 3)
  3. k - Go up one line (to line 1)
  4. P - Paste on line(s) above current line (pastes to lines 1 and 2, putting you on the new line 3)
  5. G - Go to the bottom of the buffer (line 5)
  6. P - Same as above (pastes to lines 5 and 6, or "after line 4")

As a side note, while I don't believe this question is off-topic for Arqade, you might try checking over at the Vi and Vim Stack Exchange for tips. Also when in Vim, :help <key or term> is a really useful item when figuring out how to do something. Even if your search doesn't get you exactly what you want, it might get you close in the actual help documentation.

1
  • Perfect had an unnecessary keystroke on 2dd so using dj works
    – uroboros
    Apr 27, 2020 at 21:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .