Sei sulla pagina 1di 2

Tips and Tricks

Speed up your productivity by practicing the following tips and tricks. A complete list is
available in Help documents of Eclipse. Select Tips and Tricks from Help menu.
Workbench
Now, where
was I?
Workbench editors keep a navigation history. If you open a second editor while you're
editing, you can press Navigate > Backward (Alt+Left Arrow, or the back arrow on the
workbench toolbar) to go back to the last editor. This makes working with several open
editors a whole lot easier.
Ctrl+3 Quick
Access
You can quickly find all manner of contributions with the Ctrl-3 binding including (but not
limited to) open editors, available perspectives, views, preferences, wizards, and
commands. Simply start typing the name of the item you wish to invoke and we will
attempt to find something in the Workbench that matches the provided string.
Ctrl+E Editor
List
You can quickly switch editors using the Ctrl+E keybinding which opens a list of all open
editors. The list supports type-ahead to find the editor as well as allows you to close
editors using a popup menu or the Delete key.
Editing
Content
assist
Content assist provides you with a list of suggested completions for partially entered
strings. In the J ava editor press Ctrl+Space or invoke Edit > Content Assist.
Go to last
edit location
Navigate > Go to Last Edit Location (Ctrl+Q) takes you back to the place where you
last made a change.
Parameter
hints
With the cursor in a method argument, you can see a list of parameter hints. In the J ava
Editor press Ctrl+Shift+Space or invoke Edit > Parameter Hints.
Quick Fix The J ava editor offers corrections to problems found while typing and after compiling. To
show that correction proposals are available for a problem or warning, a 'light bulb' is
visible on the editor's annotation bar. Left click on the light bulb or invoking Ctrl+1
(Edit > Quick Fix) brings up the proposals for the problem at the cursor position.
See Help->Help Contents->J ava Dev. User Guide->References->Available Quick Fixes
for the complete list of available code fixes.
Quick Assist Quick assists perform local code transformations. They are invoked on a selection or a
single cursor in the J ava editor and use the same shortcut as quick fixes (Ctrl+1).
See Help->Help Contents->J ava Dev. User Guide->References->Available Quick
Assists for the complete list of available code transformations.
Invert if statements
Convert 'switch' into 'if-else'
Replace 'if-else' with conditional
Amongst them are
Fix your code
indentation
with one key
stroke
A useful feature is Source > Correct Indentation or Ctrl+I.
Select the code where the indents are incorrect and invoke the action.
If nothing is selected, the action indents the current line.
Eclipse Tips and Tricks
CS125 Page 1
Code navigation and reading
Open on a
selection in the
Java editor
Select the reference in the code and press F3 (Navigate > Open Declaration)
Hold Ctrl, move the mouse pointer over the reference, and click the hyperlink
There are two ways that you can open an element from a reference in the J ava editor.
In-place
outlines
Press Ctrl+F3 in the J ava editor to pop up an in-place outline of the element at the
current cursor position. Or press Ctrl+O (Navigate > Quick Outline) to pop up an in-
place outline of the current source file.
Go to next /
previous
method
To quickly navigate to the next or previous method or field, use
Ctrl+Shift+Arrow Up (Navigate > Go To > Previous Member) or Ctrl+Shift+Arrow
Down (Navigate > Go To > Next Member)
Debugging
Variable values
in hover help
When execution is suspended and the cursor is placed over a variable in the J ava
editor, the value of that variable is displayed as hover help.
Creating watch
items
A watch item is an expression in the Expressions view whose value is updated as
you debug. You can create watch items from the J ava editor by selecting an
expression or variable and choosing Watch from its context menu or the top-level
Run menu.
Hot code
replace
This lets you make changes to code you are currently debugging. Note that some
changes such as new or deleted methods or class variables cannot be hot swapped.
Debugging Shortcut Keys in Eclipse
Key Function
F5 Step into
F6 Step over
F7 Step return
F8 Resume
Ctrl-R Run to line
F11 Debug Last Launched
Ctrl-Shift-B Toggle line breakpoint
CS125 Page 2

Potrebbero piacerti anche