Monday, July 27, 2009

Mouse-less Eclipse

Last updated on July 29, 2009

A fellow blog reader commented on a post I made last month titled The IDE vs Editor War in the Ruby World, asking how I actually use Eclipse in a mouse-less way. So, I decided to post a list of all Eclipse shortcuts that I find practical enough to use in my day-to-day work. Note that my focus will be mostly on text editing shortcuts as opposed to language specific shortcuts.

Mouse-less Eclipse Keyboard Shortcuts:

  • CTRL+SHIFT+L: lists all available shortcuts (useful for learning)
  • CTRL+SHIFT+R: lookup up a resource (e.g. html, xml, rb, erb, properties, etc...)
  • CTRL+SHIFT+T: lookup a class name (e.g. String or Customer)
  • CTRL+F6: quickly jump between open files
  • CTRL+E: jump between open files using a filename filter or navigation keys
  • ALT+LEFT and ALT+RIGHT: navigate back and forth in the history of the files I opened. I rely on this one a lot to avoid using the mouse when navigating back and forth between different classes that collaborate to get a user interaction handled.
  • CTRL+O: lookup a method (thanks Kristian for reminding me)
  • F3: jump to method, class, or variable declaration.
  • CTRL+J keyword: instant search of a keyword within a file
  • CTRL+F keyword then ENTER: regular search.
  • CTRL+K and CTRL+SHIFT+K: find next and find previous repeating search for the last keyword
  • Highlight text to find other occurrances of a keyword and then CTRL+K: lets you find a keyword without even typing it if you see one occurrence already in the file (for example, you see a use of the slow performing method "reindex" and you wonder where else it's used in the file)
  • CTRL+H: project-wide search for a keyword. You can also specify file patterns. Make sure to tab into fields or use mnemonics and hit ENTER instead of using the mouse. Once the search completes, pick the result you want using the up/down arrows and then hit enter to open the file.
  • HOME/END/PGUP/PGDN: for navigation of course. I've been surprised many times by how very few developers rely on these buttons to navigate a file efficiently without using the mouse.
  • CTRL+LEFT and CTRL+RIGHT: jump between words for quicker navigation in a line without taking hand off keyboard to use the mouse.
  • CTRL+SHIFT+LEFT and CTRL+SHIFT+RIGHT: quick highlighting of words without taking hand off keyboard to use the mouse.
  • CTRL+L: jump to a particular line number. I keep line numbers visible to quickly locate stack trace errors. This one is invaluable in saving me from paging through a file or using the mouse.
  • CTRL+ALT+DOWN (or UP): clones a line downwards. It's like copy/paste without using the clipboard, which I use often to avoid emptying the clipboard from something I've copied that I'd like to paste somewhere. This is most useful with the CTRL+UP/DOWN shortcuts.
  • CTRL+UP and CTRL+DOWN: moves a line up or down quickly. I often start by cloning a line, and then I move the cloned line down or up to the place I want it to be at.
  • CTRL+SHIFT+F: format content (makes sure everything is indented nicely)
  • ALT+SHIFT+UP: highlights an entire variable name even if it had underscores and multiple words
  • ALT+W P: access preferences via ALT+character mnemonics
  • ALT+character mnemonics in general: useful to do all upper menu navigation instantly without a mouse if you're on Linux or Windows (sorry Mac people). Over time, your nervous system ends up memorizing a lot of the character sequences, saving you from having to even read the menu items, let alone pointing at them with a mouse and clicking them.
Additionally, there are many shortcuts for refactoring and source generation, which I will leave for the readers to discover on their own through the menus of Eclipse.

If I remember more shortcuts over the next few days, I will make sure to update the list above. Although anyone can look up shortcuts in the Eclipse keys preferences page, not all shortcuts are practical, so I am only highlighting the ones that I consistently use to increase productivity and flow. Of course, there may be shortcuts that I have not learned to appreciate yet, so feel free to contribute in the comments the shortcuts you normally like to use.

How do I know about all these shortcuts? Did I learn them all from a reference? How can I keep learning more shortcuts in my day-to-day job? I'll leave the answers to these questions to a future blog post.


Kristian said...

You should also mention Ctrl-O (I guess that's what it is on Windows / Linux, on Mac it's Cmd-O), which lets you very quickly find symbols in a class.

Lars Vogel said...

Ctrl+ Shift + L - twice opens also the preference dialog :-)

I also keep a list of my preferred shortcasts here:

Unknown said...

Don't forget the ultimate CTRL+3. It opens the Quick Access dialog.

In the quick access dialog, just type the name of any command, preference, wizard, view, perspective, etc.

Chathurika Sandarenu said...

My favorites are
Ctrl + Shift + F - Format code
Ctrl + Shift + O - organize imports

Ctrl+ Shift + L - also list all available short cuts. So if you forget can have a quick look very easily.

Lars Vogel said...


better use save actions ( ) instead of

Ctrl + Shift + F - Format code
Ctrl + Shift + O - organize imports

Trương Xuân Tính said...

F3 - Open declaration
F4 - Open type hierarchy
Ctrl + 1 - Quick fix
Alt + Shift + S - Source generation related operation such as getter/setter
Alt + Shilft + Z - Try/catch exception

Unknown said...

Ctrl+M : Maximize Editor/View.

Alos, I tend to re-assign some frequently used short cuts.

Here are my preferred re-assigned short cut keys:
Ctrl+Tab : Next Editor (Instead of Ctrl+F6)
Shift+Ctrl+Tab : Previous Editor (Instead of Ctrl+F6)
Alt+Ctlr+B : Skip All Breakpoints (Toggle)
Ctrl+; : Quick Acess (Instread of Ctrl+3) . Have recently started using this one, by far the most useful.

Finally, one task am not able to do "mouse-less" is clear console, not even using Alt+Something, Something etc... any solution for that? Am hoping Eclipse will allow me to assign a shortcut for it someday unless am already missing something...

Sageniuz said...

Ctrl + 3 Best Eclipse shortcut

Unknown said...

Is there a shortcut to terminate the currently launched application?

Unknown said...

You might want to check out this mug:

Requests for mugs to :-)

Andy Maleh said...

Chris, if the application had its own separate window, you could ALT+TAB to it and hit ALT+F4 or CTRL+W.

However, I'm assuming you're talking about applications launched in the background and traced by the Eclipse console.

In their case, you would probably need to switch to the debug view as it shows running processes, and then through ALT+mnemonics do Run > Terminate.

If others know of other ways of how to do this, please feel free to chime in.

Unknown said...

Dude - awesome page, massive time saver :D

If I could add one more as I'm a sucker for auto-generated stubs and quick-fixes - you can access "quick fixes" by moving the cursor over whatever is annoying you with Eclipse's red/yellow underline and hit "F2".