396
votes

What is the keyboard short cut in Eclipse to jump to the closing brace of a scope?

7
As a bonus you can also press ALT + Shift + UP to select everything between those brackets.RafaelLopes
the above short cut is useful, even though a bit long, which you can still customize yourself ~~engineer
@RafaelLopes As per @romaintaz's answer, you can accomplish the same thing by double clicking. In fact, it seems like alt + shift + up is universally equivalent to double clicking at the cursor's location, according to my brief experimentation.Muhd
In the HTML editor ALT + Shift + UP keeps expanding the selection as you keep pressing it and ALT + Shift + DOWN contracts it. Combine that with ALT + UP/DOWN to move the code around = very handy.Daniel Sokolowski
@Muhd, double clicking is not exactly the same as it excludes the bracesChristophe Roussy

7 Answers

515
votes

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.

129
votes

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.

80
votes

With Ctrl + Shift + L you can open the "key assist", where you can find all the shortcuts.

20
votes

On the Macintosh, place the cursor after either the opening or closing curly brace } and use the keys: Shift + Command + P.

18
votes

To select content use Alt + Shift + Up arrow

To select content up to the next wrapping block press this shortcut again

To go back one step press Alt + Shift + Down arrow. This is also a useful shortcut when you need to select content in a complex expression and do not want to miss something.

17
votes

Press Ctrl + Shift + P.

Before Eclipse Juno you need to place the cursor just beyond an opening or closing brace.

In Juno cursor can be anywhere in the code block.

11
votes

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.