Using Structured Selection
Structured Selection lets you quickly select Java code in a syntax-aware way.
To use Structured Selection:
- In a Java editor, (optionally) select some text and press Alt+Shift+Arrow Up or select Edit > Expands Selection To > Enclosing Element from the menu bar.
- The current text selection is expanded to the inner-most syntax element (more precisely, Abstract Syntax Tree node) that encloses the selection.
When a statement or a list of statements is selected, you can press Alt+Shift+Arrow Right or select Edit > Expands Selection To > Next Element, which will expand the selection with the statement (if any exists) that is immediately after the selected statements.
When a statement or a list of statements is selected, you can press Alt+Shift+Arrow Left or select Edit > Expands Selection To > Previous Element, which will expand the selection with the statement (if any exists) that is immediately before the selected statements.
Pressing Alt+Shift+Arrow Down or selecting Edit > Expands Selection To > Restore Last Selection from the menu bar lets you restore the previous structured selection.
Using the Java editor
Using Surround with Try/Catch
Extracting a method
Extracting a local variable
Inlining a local variable
Replacing a local variable with a query