Hidden features of Eclipse [closed]

2019-01-01 14:09发布

Alright it can be a lame question, but everybody uses these things differently. What's some of the best time savers out there for this IDE.

Tom

标签: java eclipse ide
30条回答
梦醉为红颜
2楼-- · 2019-01-01 14:15

Ctrl + Shift + M: changes a static method or static attribute reference of a class to a static import.

Before

import X;

...
X.callSomething();

After

import static X.callSomething;

...
callSomething();
查看更多
与君花间醉酒
3楼-- · 2019-01-01 14:15

A non-keyboard shortcut trick is to use commit sets in your Team->Synchronise view to organise your changes before committing.

Set a change set to be the default, and all changes you make on files will be put in that set, making it easy to see what you have changed while working on a specific defect/feature, and other changes you had while testing etc.

查看更多
浪荡孟婆
4楼-- · 2019-01-01 14:18

Nobody's mentioned the best one yet. Click on a class or method name and press Ctrl+T.

You get a quick type hierarchy. For a class name you see the entire class hierarchy. For a method name you get the hierarchy showing superclasses and subclasses, with implementations of that method distinguished from abstract mentions, or classes that don't mention the method.

This is huge when you are at an abstract method declaration and quickly want to see where it is implemented.

查看更多
像晚风撩人
5楼-- · 2019-01-01 14:20

There's an option to place the opening curly brace and a semicolon automagically in the "correct" position. You'll have to enable this - Choose Window/Preferences and type "brace" in the searchbox - should be easily findable (no eclipse on this computer). The effect:

  • Typing a semicolon anywhere on the line will place it at this lines end (as in word/openoffice: Backspace if you'd like to have it in the original place)
  • Typing an opening curly brace when you're just inside another pair of braces will place it at the end of this line - as in this example

("|" is the cursor):

if(i==0|)

typing "{" now will result in

if(i==0) {|
查看更多
何处买醉
6楼-- · 2019-01-01 14:21

Ctrl+Shift+O to organize imports, which will format them nicely, remove unneeded imports, and add missing imports.

查看更多
若你有天会懂
7楼-- · 2019-01-01 14:22

Here is my collection of the most useful keyboard shortcuts for Eclipse 3:

Eclipse 3 Favorite Keyboard Shortcuts. 
by -=MaGGuS=-

Navigate:

•   Ctrl + Shift + L – Shows useful keyboard shortcuts in popup window 
•   Ctrl + H – Search.
•   Ctrl + K – Goes to next search match in a single file. Shift + Ctrl + K – goes to previous match.
•   F3 - Goes to ‘declaration’ of something. Same as Ctrl + Click.
•   Ctrl + Shift + G - Use this on a method name or variable. It will search for references in the code (all the code) to that item.
•   Ctrl + O – Shows outline view of the current class or interface.
•   Ctrl + T – Shows class hierarchy of the current class or interface. F4 – shows the same in separate tab.
•   Ctrl + Shift + T - Open Type. Search for any type globally in the workspace.
•   Ctrl + Shift + R – Open Resource. Search for any file inside workspace.
•   Ctrl + J – Incremental search. Similar to the search in firefox. It shows you results as you type. Shift + Ctrl +J - Reverse incremental search.
•   Ctrl + Q – Goes to the last edit location.
•   Ctrl + Left|Right – Go Back/Forward in history.
•   Ctrl + L – Go to line number.
•   Ctrl + E – This will give you a list of all the source code windows that are currently open. You can arrow up or down on the items to go to a tab.
•   Ctrl +PgUp|PgDown – Cycles through editor tabs.
•   Ctrl + Shift + Up|Down - Bounces you up and down through the methods in the source code.
•   Ctrl + F7 – Switches between panes (views).
•   Ctrl + ,|. – Go to the previous/next error. Great in combination with Ctrl + 1.
•   Ctrl + 1 on an error – Brings up suggestions for fixing the error. The suggestions can be clicked.
•   Ctrl + F4 – Close one source window.

Edit:

•   Ctrl + Space – Auto-completion.
•   Ctrl + / – Toggle comment selected lines.
•   Ctrl + Shift + /|\ – Block comment/uncomment selected lines.
•   Ctrl + Shift + F – Quickly ‘formats’ your java code based on your preferences set up under Window –> Preferences.
•   Ctrl + I – Correct indentations.
•   Alt + Up|Down – move the highlighted code up/down one line. If nothing is selected, selects the current line.
•   Ctrl + D – Delete row.
•   Alt + Shift + Up|Down|Left|Right – select increasing semantic units.
•   Ctrl + Shift + O – Organize Imports.
•   Alt + Shift + S – Brings up “Source” menu.
o   Shift + Alt + S, R – Generate getter/setter.
o   Shift + Alt + S, O – Generate constructor using fields.
o   Shift + Alt + S, C – Generate constructor from superclass.
•   Alt + Shift + T – Brings up “Refactor” menu.
•   Alt + Shift + J – Insert javadoc comment.
•   F2 – Display javadoc popup for current item. Shift + F2 – Display javadoc in external browser.

Run/Debug:

•   F11 / Ctrl + F11 – Execute/debug.
•   Ctrl + Shift +B – Toggle breakpoint.
•   When paused: F5 – Step into, F6 – Step over, F7 – Step out, F8 – Resume.
•   Ctrl + F2 – Terminate.

EOF
查看更多
登录 后发表回答