2

In Vim-Adventures, I'm trying to delete several lines in the same time, but I don't even know how to to that.

enter image description here

In the following video, they use d% to remove this line, but it doesn't work for me.

Thanks in advance!

1

1 Answer 1

1

I love this game! Thanks for an excuse to play it again.

To remove the 3 lines within the 5 keystroke limit, you need either the % key or the G key.

Go back near start for G key. Percent key.

  1. Enter the puzzle on the i in if.
  2. Use $ to get to the end of the line.
  3. Use % to move to the matching } tile, which is down two lines.
  4. Use j to move down into the else { line.
  5. Use d% or dG to delete the 3 red lines.

Or:

  1. Enter on the i in if.
  2. Use G to move to the last line.
  3. Use kk to move up two lines.
  4. Use dG or d% to delete the specified text.

Red text deleted, releasing a key and a NPC.

Happy Vimming!

2
  • 1
    I don't get it, why does % solve the puzzle? It did for me but I am not standing on a matching parenthesis when I'm trying to delete those lines... Jul 16, 2020 at 14:30
  • The % finds matching enclosure punctation -- i.e., ( ), [ ], and { }, even across multiple lines of text. It doesn't matter where in the line the cursor is, as long as that line contains one of the enclosurepuncts you're matching. Vim % will even find the correct level of nested enclosure punctuations. BUT, if the line where your cursor is contains multiple enclosurepuncts, then Vim will match the first one after the cursor position. (That's why $ is necessary on the if (practice) { line -- multiple enclosurepuncts; but not on the else { line -- only one enclosurepunct.)
    – m_mlvx
    Jul 21, 2020 at 22:06

You must log in to answer this question.

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