In Vim-Adventures, I'm trying to delete several lines in the same time, but I don't even know how to to that.
In the following video, they use d%
to remove this line, but it doesn't work for me.
Thanks in advance!
In Vim-Adventures, I'm trying to delete several lines in the same time, but I don't even know how to to that.
In the following video, they use d%
to remove this line, but it doesn't work for me.
Thanks in advance!
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.
i
in if
.$
to get to the end of the line.%
to move to the matching }
tile, which is down two lines.j
to move down into the else {
line.d%
or dG
to delete the 3 red lines.Or:
i
in if
.G
to move to the last line.kk
to move up two lines.dG
or d%
to delete the specified text.Happy Vimming!
%
solve the puzzle? It did for me but I am not standing on a matching parenthesis when I'm trying to delete those lines...
Commented
Jul 16, 2020 at 14:30
%
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.)
I think the problem is with the game. When I used $
to jump to the {
character there was no problems. But if I use f{
I will get an error message later when I press d%
to delete the rest of the lines.