What is the keyboard short cut in Eclipse to jump to the closing brace of a scope?
7 Answers
Place the cursor next to an opening or closing brace and punch Ctrl + Shift + P to find the matching brace. If Eclipse can't find one you'll get a "No matching bracket found" message.
edit: as mentioned by Romaintaz below, you can also get Eclipse to auto-select all of the code between two curly braces simply by double-clicking to the immediate right of a opening brace.
As the shortcut Ctrl + Shift + P has been cited, I just wanted to add a really interesting feature: just double-click to the immediate right of the {
, and Eclipse will select the whole code block between the opening {
and corresponding closing }
. Similarly, double-click to the immediate left of the closing '}' and eclipse will select the block.
I found that if the chosen perspective doesn't match the type of the current file, then "go to matching brace" doesn't work. However, changing perspectives makes it work again. So, for example, when I have a PHP file open, but, say, the Java perspective active, pressing Ctrl + Shift + P does nothing. For the same file with the PHP perspective active, pressing Ctrl + Shift + P does exactly what you'd expect and puts my cursor beside the closing brace relative to the one it started at.
alt + shift + up
is universally equivalent to double clicking at the cursor's location, according to my brief experimentation. – MuhdALT + Shift + UP
keeps expanding the selection as you keep pressing it andALT + Shift + DOWN
contracts it. Combine that withALT + UP/DOWN
to move the code around = very handy. – Daniel Sokolowski