ChatGPT解决这个技术问题 Extra ChatGPT

Eclipse jump to closing brace

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

As a bonus you can also press ALT + Shift + UP to select everything between those brackets.
the above short cut is useful, even though a bit long, which you can still customize yourself ~~
@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.
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.
@Muhd, double clicking is not exactly the same as it excludes the braces

A
Abdull

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.


The same accelerator also works for matching parens () and square brackets [].
Is there a way to select up to matching brace? Visual Studio does this using Ctrl+Shift+] (Ctrl+] means match brace; Shift means select; so Ctrl+Shift+] means select to matching brace... )
@AgnelKurian - If you look at @Romaintaz's answer below, you will note "that a double-click to the immediate right of the { will select the whole code block..."
@ninesided - Agnel wants to select from current location to end of block, not the whole; like Shift+End selects from current location to EOL. Btw, I think it's not possible (which matching would you select till? "})]" ), since Ctrl+Shift+P works with all kinds of brackets, while VS only does with braces.
For me this only works with JAVA. When I edit javascript code inside an JSP file, it doesn't work.
J
Jasper

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.


Thanks for the tip. This also works for square brackets, parentheses, and double quotes.
I am using Ruby DLTK plugin with eclipse kepler in Ruby perspective. . This does not work for ruby, where do == { and end == }.
J
Jasper

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


J
Jasper

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


C
Christophe Roussy

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.


m
mmm

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.


The steps to turn this cool feature on: Window -> Preferences -> Java -> Editor-> Bracket highlighting -> Enclosing brackets
J
Jasper

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.