Eclipse Short cuts


1. Manage Files and Projects
Ctrl+NCreate new project using the Wizard
Ctrl+Alt+nCreate new project, file, class, etc.
Alt+f, then .Open project, file, etc.
Ctrl+Shift+rOpen Ressource (file, folder or project)
Alt+EnterShow and access file properties
Ctrl+sSave current file
Ctrl+Shift+sSave all files
Ctrl+wClose current file
Ctrl+Shift+wClose all files
F5Refresh content of selected element with local file system
▲ up
minus2. Editor Window
Focus/ cursor must be in Editor Window for these to work.
F12Jump to Editor Window
Ctrl+Page Down/Ctrl+Page UpSwitch to next editor / switch to previous editor
Ctrl+mMaximize or un-maximize current Editor Window (also works for other Windows)
Ctrl+eShow list of open Editors. Use arrow keys and enter to switch
Ctrl+F6/Ctrl+Shift+F6Show list of open Editors. Similar to ctrl+e but switches immediately upon release of ctrl
Alt+Arrow Left/Alt+Arrow RightGo to previous / go to next Editor Window
Alt+-Open Editor Window Option menu
Ctrl+F10Show view menu (features available on left vertical bar: breakpoints, bookmarks, line numbers, …)
Ctrl+F10, then nShow or hide line numbers
Ctrl+Shift+qShow or hide the diff column on the left (indicates changes since last save)
▲ up
minus3. Navigate in Editor
Home/EndJump to beginning / jump to end of indention. Press home twice to jump to beginning of line
Ctrl+Home/EndJump to beginning / jump to end of source
Ctrl+Arrow Right/Arrow LeftJump one word to the left / one word to the right
Ctrl+Shift+Arrow Down/Arrow UpJump to previous / jump to next method
Ctrl+lJump to Line Number. To hide/show line numbers, press ctrl+F10 and select 'Show Line Numbers'
Ctrl+qJump to last location edited
Ctrl+./Ctrl+,Jump to next / jump to previous compiler syntax warning or error
Ctrl+Shift+pWith a bracket selected: jump to the matching closing or opening bracket
Ctrl+[+]/Ctrl+- on numeric keyboardCollapse / Expand current method or class
Ctrl+[/]/Ctrl+* on numeric keyboardCollapse / Expand all methods or classes
Ctrl+Arrow Down/Ctrl+Arrow UpScroll Editor without changing cursor position
▲ up
minus4. Select Text
Shift+Arrow Right/Arrow LeftExpand selection by one character to the left / to the right
Ctrl+Shift+Arrow Right/Arrow LeftExpand selection to next / previous word
Shift+Arrow Down/Arrow UpExpand selection by one line down / one line up
Shift+End/HomeExpand selection to end / to beginning of line
Ctrl+aSelect all
Alt+Shift+Arrow UpExpand selection to current element (e.g. current one-line expression or content within brackets)
Alt+Shift+Arrow Left/Arrow RightExpand selection to next / previous element
Alt+Shift+Arrow DownReduce previously expanded selection by one step
▲ up
minus5. Edit Text
Ctrl+c/Ctrl+x/Ctrl+vCut, copy and paste
Ctrl+zUndo last action
Ctrl+yRedo last (undone) action
Ctrl+dDelete Line
Alt+Arrow Up/Arrow DownMove current line or selection up or down
Ctrl+Alt+Arrow Up / Ctrl+Alt+Arrow Down /Duplicate current line or selection up or down
Ctrl+DeleteDelete next word
Ctrl+BackspaceDelete previous word
Shift+EnterEnter line below current line
Shift+Ctrl+EnterEnter line above current line
InsertSwitch between insert and overwrite mode
Shift+Ctrl+yChange selection to all lower case
Shift+Ctrl+xChange selection to all upper case
▲ up
minus6. Search and Replace
Ctrl+fOpen find and replace dialog
Ctrl+k/Ctrl+Shift+kFind previous / find next occurrence of search term (close find window first)
Ctrl+hSearch Workspace (Java Search, Task Search, and File Search)
Ctrl+j/Ctrl+Shift+jIncremental search forward / backwards. Type search term after pressing ctrl+j, there is now search window
Ctrl + Shift + oOpen a resource search dialog to find any class
▲ up
minus7. Indentions and Comments
Tab/Shift+TabIncrease / decrease indent of selected text
Ctrl+iCorrect indention of selected text or of current line
Ctrl+shift+fAutoformat all code in Editor using code formatter
Ctrl+/Comment / uncomment line or selection ( adds '//' )
Ctrl+Shift+/Add Block Comment around selection ( adds '/... */' )
Ctrl+Shift+\Remove Block Comment
Alt+Shift+jAdd Element Comment ( adds '/** ... */')
▲ up
minus8. Editing Source Code
Ctrl+SpaceOpens Content Assist (e.g. show available methods or field names)
Ctrl+1Open Quick Fix and Quick Assist
Alt+/Propose word completion (after typing at least one letter). Repeatedly press alt+/ until reaching correct name
Ctrl+Shift+InsertDeactivate or activate Smart Insert Mode (automatic indention, automatic brackets, etc.)
▲ up
minus9. Code Information
Ctrl+oShow code outline / structure
F2Open class, method, or variable information (tooltip text)
F3Open Declaration: Jump to Declaration of selected class, method, or parameter
F4Open Type Hierarchy window for selected item
Ctrl+tShow / open Quick Type Hierarchy for selected item
Ctrl+Shift+tOpen Type in Hierarchy
Ctrl+Alt+hOpen Call Hierarchy
Ctrl+uFind occurrences of expression in current file
Ctrl+move over methodOpen Declaration or Implementation
▲ up
minus10. Refactoring
Alt+Shift+rRename selected element and all references
Alt+Shift+vMove selected element to other class or file (With complete method or class selected)
Ctrl+Shift+cChange method signature (with method name selected)
Alt+Shift+mExtract selection to method
Alt+Shift+lExtract local variable: Create and assigns a variable from a selected expression
Alt+Shift+iInline selected local variables, methods, or constants if possible (replaces variable with its declarations/ assignment and puts it directly into the statements)
▲ up
minus11. Run and Debug
Ctrl+F11Save and launch application (run)
F11Debug
F5Step Into function
F6Next step (line by line)
F7Step out
F8Skip to next Breakpoint
▲ up

minus12. The Rest
Ctrl+F7/Ctrl+Shift+F7Switch forward / backward between views (panels). Useful for switching back and forth between Package Explorer and Editor.
Ctrl+F8/Ctrl+Shift+F8Switch forward / backward between perspectives
Ctrl+pPrint
F1Open Eclipse Help




CTRL + D

Delete row. Try it! You no more need to grab the mouse and select the line, no more Home, Shift + End, Delete. Quick and clean.
ALT + Up/Down Arrow

Move the row (or the entire selection) up or down. Very useful when rearranging code. You can even select more rows and move them all. Notice, that it will be always correctly indented.
ALT + Left/Right Arrow

Move to the last location you edited. Imagine you just created a class Foo, and now you are working on a class Boo. Now, if you need to look at the Foo class, just press Alt+Left Arrow. Alt+Right Arrow brings you back to Boo.

CTRL+SHIFT+O

Organize imports. What happens when you first use a class you have not yet imported? You will see an error. But when you press this magical combination, all your missing classes will be imported, and the unused imports will vanish.

CTRL+1

Probably the most useful one. It activates the quick fix. Imagine you create a class, which implements some interface. You will get an error, because the inherited methods are not yet implemented. While you are on line where the error occurs, press this combination to activate the quick fix. Now, select the "Add unimplemented methods" option. You can use the quick fix at every error you ever receive.
Quick fix comes handy in other situations too. My favorite is the "Split variable declaration". Sometimes I need to broaden the scope of a variable. I activate the quick fix, split declaration, and use alt + arrow to put it where it belongs. You can find even more usages: Convert local variable to field, rename in file, Inline local variable..
You could use the "Split variable declaration" on the bar variable, and then move it with Alt+Arrows above the try block..
Or you could use the "Add unimplemented methods" fix here.
The best thing you can do if you see an error is to use the quick fix.
CTRL+SHIFT+T

Open Type. Imagine, that you need to have a look at the Foo class. But, where is the Foo class? Is it in the Boo project and in the foo.bar package? Or somewhere else? With this shortcut, you don't need to know. Just press it, type Foo and you are in.
CTRL+E

Shows you a list of all open editors.


CTRL+F6

Use to move between open editors. This is an slower alternative to Ctrl + E. Comes handy in a situation when you want to periodically switch between two editors, something, what is nearly impossible with Ctrl+E as it sorts entries quite randomly. Or you might just use Alt+Arrows..

CTRL+F7

Move between views. When in editor, press Ctrl+F7 to switch to the Package Explorer, or hold Ctrl and press F7 multiple times to switch to other views.
CTRL+F8
Move between perspectives. The same as previous.

CTRL + F11


Runs the application. What gets launched depends on your settings. It will either launch the last launched class (my preffered way) or it will launch currently selected resource (the default way). If you want to change its behavior read the previous post.

CTL + N


Open new type wizard. This is not very quick because you have to select the wizard type (weather you want to create new class, jsp, xml or something else) in the next step. Much faster way would be if you could just hit the shortcut and invoke the particular wizard. It is possible, just keep reading..

CTRL + M

Maximize or umaximize current tab.

CTRL + I


Corrects indentation.

CTRL + SHIFT + F

Formats code. You can make a beautiful looking code out of a mess with this. It requires a bit of setup, but it is well worth it. You can find its settings under Window->Preferences->Java->Code style->Formatter

CTRL + J


Incremental search. Similar to the search in firefox. It shows you results as you type. Don't be surprised, if you hit this combination, nothing happens - at the first glance. Just start typing and eclipse will move your cursor to the first ocurence.

CTRL + SHIFT + L

Shows you a list of your currently defined shortcut keys.

I don't like your shortcuts

Such is life nowadays. Remember, you can always change those bindings to match your preferences. Open Windows->Preferences->General->Keys. Now you can use the filter to find your shortcut and change its binding.
The real fun begins when you cannot find the command you are looking for. The key here, is to have the "Include unbounds commands" checkbox checked. It will show you all commands, even those, which have no keys bound.
While you are here, I recommend to add the following bindings:

CTRL+SHIFT+G

Bind this to "Generate getters and setters". This is a "must have".

ALT+C

Bind this to SVN/CVS "Commit".

ALT+U


Bind this to SVN/CVS "Update".

Now, type "new" (without quotes) in the filter text. You should see a list of all new type wizards. Choose the most frequently used and assign them a shortcut. For example, the most used wizard for me is the new class wizard. Thus I assigned it the CTRL+SHIFT+N keys.

Let me demonstrate a quick way to create new class now.

Hit CTRL + SHIFT + N (or the combination you assigned in the previous step). This should bring up new class wizard. Type in the name and press ALT+E. You can now select a class which will be a superclass for the newly created class. Hit ALT+A and select all implemented interfaces . Now hitALT+F and your class will be generated. Eclipse will also provide the default implementation for all abstract and interface methods you inherited.

Did you notice the weird underscores everywhere in the dialog? They give you a hint about the shortcut key. Hit ALT and the underlined letter to press the button, check the checkbox or get focus for a textfield.
Did you notice the underscores?

I think that using shortcut keys is the fastest way to productivity and if not, then at least your wrists will say you a silent thanks. Now, don't wait, go on and assign keys to the features you use most.
One final tip from Andriy:
The problem is that there are so many keyboard shortcuts. I used to keep a printout with all the shortcuts I wanted to use. Finally I wrote an Eclipse plugin MouseFeed, which reminds the keyboard shortcuts for the actions called with mouse. You can even tell it to enforce some shortcuts - the action will run only if called with a keyboard shortcut.
So if you are struggling with yourself, if you want to use shortcuts, but always subconsciously touch the mouse, install the plugin and let it enforce the shortcuts - the mouse will be useless and you will be forced to use keyboard.
What shortcuts do you use?
References
Published at DZone with permission of its author, Tomas Kramar. (source)
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)
Tags:

Comments



Mark Haniford replied on Fri, 2008/02/15 - 7:48am

Nice


Cole Markham replied on Fri, 2008/02/15 - 10:15am

Very good overview of the most useful shortcuts. I really like the new class shortcut, I find myself wanting that all the time, and I always forget that almost everything in Eclipse can have a key binding even if it doesn't already.
One thing I noticed is that you map CTRL+SHIFT+G to "Generate getters and setters". That's a great shortcut, and I am about to set a key binding for it. ButCTRL+SHIFT+G is mapped to "References->In Workspace" which I use all the time. Place your cursor on a class, variable or method and fire the action. This will show in the Search view all references of that item throughout your workspace. Very useful when you are trying to understand code.
A few more that I use religiously:
CTRL+ALT+H Open Call Heirarchy. Find out where that method is used.
F4 Open Type Heirarchy. See the subclasses and/or superclasses. This one can be tricky sometimes. If there is a class under the cursor it will open that class's heirarchy, if not it will use the class that contains the cursor (including inner classes).
F3 Open Declaration. Jump to the declaration of the variable, method or class. It will try to find the most specific declaration it can for methods, but depending on your code you might end up in an Interface which is probably not what you want. Then just press F4 to get the type heirarchy and find the implementation you are looking for.
ALT+SHIFT+R Refactor->Rename. Works in the editor and in the package explorer. If you haven't learned the power of refactoring, do so now. Think of this one as a super-smart Find-Replace. The new 3.3 feature of inline rename is awesome.
ALT+SHIFT+V Refactor->Move. Again, works in both the edtor and package explorer. Move the method or field to another class.
ALT+SHIFT+M Extract to method. Break up that monolithic code, takes the selection and trys to make it into a method. Will optionally find duplicate code blocks and use the new method there as well. It might take a few trys to get this to work the way you want. Just try it, rearrange thee code a little and try again.

Post a Comment

Thank You

Previous Post Next Post