Finding Matching Braces in Vim
Dec 30th, 2009 by Alex
Simply put, Shift-% will find matching braces in Vim.
my @foods = qw(rice celery apple orange potato);
my @fruits = qw(apple orange pineapple);
for my $food (@foods) {
for my $fruit (@fruits) {
if ($food eq $fruit) {
print "$fruit\n";
}
}
}
If you place the cursor on the for my $fruit (@fruits) line and hit Shift-%, the cursor will jump down to the second to last closing brace.
I’m not a big fan of code folding, so this is incredibly helpful for long loops. I feel like I should have known about this eons ago.
Vim? Are you wearing suspenders and sporting a beard?
Fucking. A.
These are exactly the sort of tips which make vim so awesome. And JJT: at least it’s not vi! Eh, you’re a windows guy, I suppose you’d prefer notepad?
JJT: Yes, no, and yes. What would you advocate, some clunky IDE?
mark: I suppose he could be an Emacs fan.