Eclipse: Difference between revisions
Jump to navigation
Jump to search
(Created page with '== Keyboard shortcuts == {| class="wikitable" width="100%" |- |width="140px"| {{kb|C-S-o}} | Generate automatically all java <tt>import</tt>. |}') |
(→Tips) |
||
(15 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== References == |
|||
* [http://www.ralfebert.de/blog/eclipseide/source_formatting/ Eclipse IDE - Java source formatting] |
|||
== Keyboard shortcuts == |
== Keyboard shortcuts == |
||
{| class="wikitable" width="100%" |
|||
|- |
|||
!width="140px"|Shortcut !! Description |
|||
|- |
|||
| {{kb|Shift-F5}} || DEBUG - REVERSE Step INTO |
|||
|- |
|||
| {{kb|F5}} || DEBUG - Step INTO |
|||
|- |
|||
| {{kb|Ctrl-F5}} || DEBUG - Step INTO SELECTION |
|||
|- |
|||
| {{kb|Shift-F6}} || DEBUG - REVERSE Step OVER |
|||
|- |
|||
| {{kb|F6}} || DEBUG - Step OVER |
|||
|- |
|||
| {{kb|F7}} || DEBUG - Step RETURN |
|||
|- |
|||
| {{kb|F8}} || DEBUG - Step RESUME |
|||
|- |
|||
| {{kb|Ctrl-R}} || DEBUG - Run TO LINE |
|||
|- |
|||
| {{kb|F11}} || DEBUG *last* launched |
|||
|- |
|||
| {{kb|Shift-2xClick}} || Breakpoint - Toggle |
|||
|- |
|||
| {{kb|Ctrl-B}} || Build ALL projects |
|||
|} |
|||
<div style="column-width:25em;"> |
|||
{| class="wikitable" width="100%" |
|||
|- |
|||
|width="140px"| {{kb|C-i}} |
|||
|Correct Indentation |
|||
|- |
|||
| {{kb|C-S-f}} |
|||
|Format |
|||
|} |
|||
{| class="wikitable" width="100%" |
{| class="wikitable" width="100%" |
||
|- |
|- |
||
|width="140px"| |
|width="140px"|{{kb|C-S-o}} |
||
|Generate automatically all java <tt>import</tt>. |
|||
{{kb|C-S-o}} |
|||
| |
|||
Generate automatically all java <tt>import</tt>. |
|||
|} |
|} |
||
{| class="wikitable" width="100%" |
|||
|- |
|||
|width="140px"| {{kb|A-{{kbname|Space}}}} {{kb|A-/}} |
|||
|Text autocomplete |
|||
|- |
|||
| Drag & Drop / CTRL - Drag & Drop |
|||
|Copy/Move object |
|||
|- |
|||
| {{kb|C-q}} |
|||
|Go to last Edit position |
|||
|- |
|||
| {{kb|F2}} |
|||
|See editable JavaDoc |
|||
|- |
|||
| {{kbname|Tab}} |
|||
|Typing tab |
|||
|- |
|||
| {{kb|C-1}} |
|||
|local rename |
|||
|- |
|||
| {{kb|C-1}} |
|||
|Quick Fix / Quick Assist (Create missing method, easy override method...) |
|||
|- |
|||
| hold CTRL |
|||
|Auto-Hyperlink when mouse's hovering |
|||
|- |
|||
| {{kb|C-S-Up}} {{kb|C-S-Down}} {{kb|C-F3}} {{kb|C-o}} |
|||
|Next declaration |
|||
|- |
|||
| {{kb|C-j}} {{kb|C-S-j}} |
|||
|Incremental Find forward/backware |
|||
|- |
|||
| {{kb|C-S-p}} |
|||
|Find Matching bracket |
|||
|- |
|||
| {{kb|C-S-hold}} |
|||
|Drag & Drop method creation |
|||
|- |
|||
| hold CTRL |
|||
|Code Assist Insert mode toggle |
|||
|- |
|||
| {{kb|C-SPACE}} |
|||
|Context Assist |
|||
|- |
|||
| {{kb|C-SPACE}} |
|||
|Code Assist |
|||
|- |
|||
| {{kb|C-S-SPACE}} |
|||
|Parameter Assist |
|||
|- |
|||
| {{kb|C-e}} |
|||
|Delete Line |
|||
|- |
|||
| {{kb|C-/}} |
|||
|Comment block |
|||
|- |
|||
| {{kb|A-{{kbname|Space}}}} |
|||
|Text Completion |
|||
|- |
|||
| {{kb|C-S-e}} |
|||
|Insert Line |
|||
|} |
|||
{| class="wikitable" width="100%" |
|||
|- |
|||
|width="140px"| {{kb|F12}} |
|||
|Activate Editor |
|||
|- |
|||
| {{kb|C-F6}} |
|||
|Next Editor |
|||
|- |
|||
| {{kb|C-S-F6}} |
|||
|Previous Editor |
|||
|} |
|||
{| class="wikitable" width="100%" |
|||
|- |
|||
|width="140px"| {{kb|F11}} |
|||
|Debug last launched |
|||
|- |
|||
| {{kb|C-F11}} |
|||
|Run last launched |
|||
|} |
|||
{| class="wikitable" width="100%" |
|||
|- |
|||
|width="140px"| {{kb|C-S-b}} |
|||
|Add/Remove Breakpoint |
|||
|} |
|||
{| class="wikitable" width="100%" |
|||
|- |
|||
|width="140px"| {{kb|C-S-u}} |
|||
|Search Occurences in File |
|||
|} |
|||
{| class="wikitable" width="100%" |
|||
|- |
|||
|width="140px"| {{kb|C-.}} |
|||
|Next Item (search, ...) |
|||
|- |
|||
| {{kb|C-,}} |
|||
|Previous Item (search, ...) |
|||
|} |
|||
{| class="wikitable" width="100%" |
|||
|- |
|||
|width="140px"| {{kb|F5}} |
|||
|Debug - Step Into |
|||
|- |
|||
| {{kb|F6}} |
|||
|Debug - Step Over |
|||
|- |
|||
| {{kb|F7}} |
|||
|Debug - Step Return |
|||
|- |
|||
| {{kb|F8}} |
|||
|Debug - Resume |
|||
|- |
|||
| {{kb|C-r}} |
|||
|Debug - Run To Line |
|||
|} |
|||
{| class="wikitable" width="100%" |
|||
|- |
|||
|width="140px"| {{kb|C-F12}} |
|||
|Show in Package Explorer (new) |
|||
|} |
|||
{| class="wikitable" width="100%" |
|||
|- |
|||
|width="140px"| {{kb|C-f}} |
|||
|Find (and Replace) |
|||
|- |
|||
| {{kb|C-k}} |
|||
|Find Next (highlight selection & press shortcut) |
|||
|- |
|||
| {{kb|C-S-k}} |
|||
|Find Previous |
|||
|- |
|||
| {{kb|C-j}} |
|||
|Find Incremental (up/down for next/previous, enter to complete) |
|||
|- |
|||
| {{kb|C-S-j}} |
|||
|Find Incremental Reverse |
|||
|} |
|||
{| class="wikitable" width="100%" |
|||
|- |
|||
|width="140px"| {{kb|F3}} |
|||
|Open Declaration |
|||
|- |
|||
| {{kb|C-o}} |
|||
|Show Outline |
|||
|- |
|||
| {{kb|C-F6}} {{kb|C-S-F6}} |
|||
|Next (Previous) Editor |
|||
|- |
|||
| {{kb|C-F7}} {{kb|C-S-F7}} |
|||
|Next (Previous) View |
|||
|- |
|||
| {{kb|C-F10}} |
|||
|Show View Menu |
|||
|} |
|||
</div> |
|||
== Plugins == |
|||
* Jalopy 0.2.6 (Obsolete - now in Eclipse) |
|||
* TabNavigator 1.1.0 |
|||
* Readonly Decorator (probably not needed today) |
|||
== Tips == |
|||
Wonder why it is called ''Eclipse''? Because important stuff are hidden. |
|||
=== Show number lines === |
|||
* Go to '''Window → Preferences → General → Editors → Text editors''', check '''Show line numbers'''. |
|||
=== Use monospace fonts for watch points, registers... === |
|||
Sick of debugger watch/register value in ''proportional'' font? |
|||
* Go to '''Window → Preferences → General → Appearance → Colors and Fonts''', select '''Debug''', and double click '''Variable text font'''. |
|||
* Select your favorite monospace font (for instance <code>Consolas 9</code>). |
|||
=== Keep Debug tab minimized === |
|||
When in debug mode, Eclipse will keep displaying the ''Debug'' tab even if you minimize it. To prevent this |
|||
* Go to '''Window → Preferences → Run/Debug'''. |
|||
* Uncheck '''Activate the workbench when a breakpoint is hit''' and '''Activate the debug view when a breakpoint is hit'''. |
|||
=== Miscellaneous debugging tips === |
|||
* If possible, disable compiler optimization (use <code>-O0</code>), or some symbols will not be available to the debugger (because in register). |
|||
* To step into disassembled code, click on button [[File:Eclipse-instr stepping button.PNG]] '''Instruction Stepping Mode''' on ''Debug'' toolbar. |
|||
=== Miscellaneous === |
|||
* Console windows truncates part of the program output → right click in console Windows → Preferences... |
|||
* Install KeyTool Plugin: |
|||
** Go to http://keytool.sourceforge.net/, '''installing''', write down the URL (typ. <tt>http://keytool.sourceforge.net/update</tt>) |
|||
** In Eclipse, ''Help'' → ''Install New Software...'' |
|||
** Type in the URL in ''Work with:'', click ''Add'', type in a ''local plugin name'', install and then restart Eclipse. |
|||
'''Note''': Don't forget to setup the proxy settings if needed (since ''Eclipse 3.6.0 Helios'' the settings of IE are used by default). |
|||
== Formatting == |
|||
'''Using Eclipse''' |
|||
Automatic code indentation and source formatting is now directly embedded in Eclipse. There is no need for an external tool like ''Jalopy'' or so. |
|||
Find it at ''Eclipse preferences'' → ''Java'' → ''Code Style'' → ''Formatter''. |
|||
Frequent shortcuts: |
|||
* {{kb|Ctrl-I}} — correct indentation |
|||
* {{kb|Ctrl-Shift-F}} — Format |
|||
'''Using Eclipse to format code''': |
|||
* http://blogs.operationaldynamics.com/andrew/software/java-gnome/eclipse-code-format-from-command-line |
|||
* http://www.peterfriese.de/formatting-your-code-using-the-eclipse-code-formatter/ |
|||
A solution: |
|||
# Go to Eclipse Formatter preferences (''Eclipse preferences'' → ''Java'' → ''Code Style'' → ''Formatter'') |
|||
# Configure the formatter as desired (possibly creating a new profile) |
|||
# Click on ''Configure Project Specific Settings...'' |
|||
# Select a project, and ''Enable project specific settings'' |
|||
# Go in the selected project workspace, and copy the file <tt>.settings/org.eclipse.jdt.core.prefs</tt> to some location of your choice (say <tt>~/etc</tt>) |
|||
# Now to format a source tree <tt>./src</tt>, do: |
|||
<source lang="bash"> |
|||
eclipse -nosplash \ |
|||
-application org.eclipse.jdt.core.JavaCodeFormatter \ |
|||
-verbose \ |
|||
-config ~/etc/org.eclipse.jdt.core.prefs \ |
|||
./src |
|||
</source> |
|||
'''External solutions''' |
|||
* [http://jalopy.sourceforge.net/existing/index.html Jalopy] (files [http://sourceforge.net/projects/jalopy/ here], yet another [http://jalopy.sourceforge.net/]) |
Latest revision as of 06:44, 21 October 2016
References
Keyboard shortcuts
Shortcut | Description |
---|---|
Shift-F5 | DEBUG - REVERSE Step INTO |
F5 | DEBUG - Step INTO |
Ctrl-F5 | DEBUG - Step INTO SELECTION |
Shift-F6 | DEBUG - REVERSE Step OVER |
F6 | DEBUG - Step OVER |
F7 | DEBUG - Step RETURN |
F8 | DEBUG - Step RESUME |
Ctrl-R | DEBUG - Run TO LINE |
F11 | DEBUG *last* launched |
Shift-2xClick | Breakpoint - Toggle |
Ctrl-B | Build ALL projects |
C-i | Correct Indentation |
C-S-f | Format |
C-S-o | Generate automatically all java import. |
A-Space A-/ | Text autocomplete |
Drag & Drop / CTRL - Drag & Drop | Copy/Move object |
C-q | Go to last Edit position |
F2 | See editable JavaDoc |
Tab | Typing tab |
C-1 | local rename |
C-1 | Quick Fix / Quick Assist (Create missing method, easy override method...) |
hold CTRL | Auto-Hyperlink when mouse's hovering |
C-S-Up C-S-Down C-F3 C-o | Next declaration |
C-j C-S-j | Incremental Find forward/backware |
C-S-p | Find Matching bracket |
C-S-hold | Drag & Drop method creation |
hold CTRL | Code Assist Insert mode toggle |
C-SPACE | Context Assist |
C-SPACE | Code Assist |
C-S-SPACE | Parameter Assist |
C-e | Delete Line |
C-/ | Comment block |
A-Space | Text Completion |
C-S-e | Insert Line |
F12 | Activate Editor |
C-F6 | Next Editor |
C-S-F6 | Previous Editor |
F11 | Debug last launched |
C-F11 | Run last launched |
C-S-b | Add/Remove Breakpoint |
C-S-u | Search Occurences in File |
C-. | Next Item (search, ...) |
C-, | Previous Item (search, ...) |
F5 | Debug - Step Into |
F6 | Debug - Step Over |
F7 | Debug - Step Return |
F8 | Debug - Resume |
C-r | Debug - Run To Line |
C-F12 | Show in Package Explorer (new) |
C-f | Find (and Replace) |
C-k | Find Next (highlight selection & press shortcut) |
C-S-k | Find Previous |
C-j | Find Incremental (up/down for next/previous, enter to complete) |
C-S-j | Find Incremental Reverse |
F3 | Open Declaration |
C-o | Show Outline |
C-F6 C-S-F6 | Next (Previous) Editor |
C-F7 C-S-F7 | Next (Previous) View |
C-F10 | Show View Menu |
Plugins
- Jalopy 0.2.6 (Obsolete - now in Eclipse)
- TabNavigator 1.1.0
- Readonly Decorator (probably not needed today)
Tips
Wonder why it is called Eclipse? Because important stuff are hidden.
Show number lines
- Go to Window → Preferences → General → Editors → Text editors, check Show line numbers.
Use monospace fonts for watch points, registers...
Sick of debugger watch/register value in proportional font?
- Go to Window → Preferences → General → Appearance → Colors and Fonts, select Debug, and double click Variable text font.
- Select your favorite monospace font (for instance
Consolas 9
).
Keep Debug tab minimized
When in debug mode, Eclipse will keep displaying the Debug tab even if you minimize it. To prevent this
- Go to Window → Preferences → Run/Debug.
- Uncheck Activate the workbench when a breakpoint is hit and Activate the debug view when a breakpoint is hit.
Miscellaneous debugging tips
- If possible, disable compiler optimization (use
-O0
), or some symbols will not be available to the debugger (because in register). - To step into disassembled code, click on button Instruction Stepping Mode on Debug toolbar.
Miscellaneous
- Console windows truncates part of the program output → right click in console Windows → Preferences...
- Install KeyTool Plugin:
- Go to http://keytool.sourceforge.net/, installing, write down the URL (typ. http://keytool.sourceforge.net/update)
- In Eclipse, Help → Install New Software...
- Type in the URL in Work with:, click Add, type in a local plugin name, install and then restart Eclipse.
Note: Don't forget to setup the proxy settings if needed (since Eclipse 3.6.0 Helios the settings of IE are used by default).
Formatting
Using Eclipse
Automatic code indentation and source formatting is now directly embedded in Eclipse. There is no need for an external tool like Jalopy or so.
Find it at Eclipse preferences → Java → Code Style → Formatter.
Frequent shortcuts:
- Ctrl-I — correct indentation
- Ctrl-Shift-F — Format
Using Eclipse to format code:
- http://blogs.operationaldynamics.com/andrew/software/java-gnome/eclipse-code-format-from-command-line
- http://www.peterfriese.de/formatting-your-code-using-the-eclipse-code-formatter/
A solution:
- Go to Eclipse Formatter preferences (Eclipse preferences → Java → Code Style → Formatter)
- Configure the formatter as desired (possibly creating a new profile)
- Click on Configure Project Specific Settings...
- Select a project, and Enable project specific settings
- Go in the selected project workspace, and copy the file .settings/org.eclipse.jdt.core.prefs to some location of your choice (say ~/etc)
- Now to format a source tree ./src, do:
eclipse -nosplash \
-application org.eclipse.jdt.core.JavaCodeFormatter \
-verbose \
-config ~/etc/org.eclipse.jdt.core.prefs \
./src
External solutions