Eclipse Tips
  • Basic eclipse stuff
    1. perspectives are sets of views
    2. minimize and restore views
    3. double click to maximize
    4. debug perspective to see whats running
    5. console
    6. perspectives
    7. installing new software
  • speed/automation tips & key shortcuts
    1. control-1 - quick fix - probably the single most useful key combo in all of eclipse. Will allow you to fix common problems, imports, build path, etc. It is even awesome for TDD - allowing you to create undefined methods, etc
    2. control-3 - search commands - try generate getters and setters
    3. control-space - autocomplete. Will complete classes, fields, methods, variables, anything in scope. Even will complete javadoc comments - definitely a top 10 key shortcut. This one shortcut should cut your total keystrokes spent typing by at least 50%
    4. control-d - delete line. delete code that isn't being used quickly
    5. alt-left and alt-right - similar to a browser this allows you to go forwards and backwards through code
    6. alt-up and alt-down - move lines or selection up and down
    7. hold control and click on elements to go to their definitions. Even works in comments! If you work on a team with a mix of TDD/unit test types and non-unit test types
    8. control-d - delete line or all lines partially or fully selected
    9. control-z - undo. Ok, this is standard in most editor apps these days, 99% of readers should know this already
    10. control-shift-tab, left or right to switch between open tabs
    11. control-shift-f - automatically format file
    12. control-alt-up or control-alt-down - clone line or selection
    13. control-alt-x, t - run as JUnit test. Also, if you wait a bit before hitting t, it will pop up a list of other run options
    14. control-F6 - pop up a list of open editors, then use mouse to click the one you want to switch to
    15. filter text - lots of windows in eclipse have the filter text in the upper right. For example, window->preferences. Try typing in topics to find things very quickly. Ex: "semi colons" to automatically insert semi colons at the end of the line. And "format" to access code formatting settings
    16. navigate to anything you know the name of quickly (for classes, use control-shift-t, then type the first few letters of the class. for all resources, control-shift-r, then type the first few letters of the resource. ? matches any character, * matches any string… )
    17. control-shift-g - find references to a method, class or field in the workspace
    18. control-k - search within a file for whatever is currently highlighted in the editor
    19. control-t - open up type heirarchy of a method or class. SUPER nice for finding all implementations of a method on an interface or abstract method
    20. control-j, start typing a few letters - incremental search through the open file
    21. control-o - pop up the outline view for the current class
    22. control-shift-o - organize imports - including getting rid of any unused imports and importing anything missing
    23. control-alt-s - source options. Includes really useful stuff like "Generate Getters and Setters…" and "Generate hashCode() and equals()…"
    24. control-alt-j - autogenerate javadoc comments for the field, method, or class your cursor is currently indicating
    25. alt-shift up / down - respectively increase or decrease the scope of a selected region of code. Very useful for selecting the entire contents of a block or method
    26. control-F11 - re-run the last thing that ran
    27. shift-enter - insert new line below the one you are working on. Saves keystrokes for the very common operation of fixing something in the middle of one line and then wanting to continue coding on the next line. Same as "o" in vi command mode
  • quality, functionality, capability
    1. control-alt-d, t - debug as JUnit test. Also, if you wait a bit before hitting t, it will pop up a list of other run options
      • F5 - step into
      • F6 - step over
      • F7 - step return
      • control-shift-i - inspect an element
    2. compare with local history - made a change and now your program doesn't work? Eclipse can save the day, as it saves a copy of your file every time the file is saved. Just right click and goto->Compare With->(History or Local History). If your project is not in version control (shame on you!), then the option will be "Local History". If it is in version control, the Local History will show up in between the revisions which are in source control.
    3. team synchronization view for source control (right click project and goto team->synchronize). I find it hard to believe this idea originated with eclipse, but that's the first time I ran into it. Very nice feature for managing a project in version control. The synchronize view simultaneously shows changes on the server (allowing you to update and bring them down) and changes on your local box (allowing you to override or commit them). Double-clicking on a file brings up a diff
    4. Actions on save - You can do some super cool stuff like run code formatting and organize imports every time you save a file
      • Window->Preferences->Java->Editor->Save Actions (or type "save" in the filter field)
    5. Quickfix create fields from constructor and setter arguments. Try the following: //public void testCreate() {ExampleClass instance = new ExampleClass(String param1, String param2)}; //
      • Click on ExampleClass, control-1 and create the class, alt-left to go back to the test, control-1 and create the constructor, click on the parameter name (defaults to string), and control-1 again - select "Assign parameter to new field". How cool is that?
    6. Working sets. If you find yourself dealing with more than 10 projects at a time, it is definitely worth the effort to organize them into working sets
    7. Run eclipse with the jdk instead of the jre. Then you will get the javadoc popups for the jdk methods and also certain plugins require a jdk.
  • troubleshooting tips
    1. project->clean - rarely Eclipse will become confused and red lines will show up all over a project. If the errors don't seem to make sense, try going to project->clean and cleaning that file or the entire workspace
    2. Increase virtual memory and permgen settings
    3. Show heap status in lower right of eclipse window: Window->Preference->General and check mark "Show heap status". Clicking trash can requests garbage collection
  • productivity pumping plugins
    1. findbugs plugin - awesome free plugin that finds common bugs in code through static analysis
    2. mylyn - some love it some don't. There are a number of things about it that are pretty awesome. Perhaps the easiest way to get into it is if you find yourself switching between a few simultaneous tasks. The bugzilla integration is also very cool. It's bundled into recent versions of eclipse by default. QuickStart at http://www.eclipse.org/mylyn/start/
    3. maven - if you are using maven, but not using the m2eclipse plugin, you need to check it out: http://maven.apache.org/eclipse-plugin.html
      • Auto complete editor for pom files, dependency graph generation, update project dependencies, run maven commands directly from eclipse, and even search the public repos for a new dependency with a few keystrokes. Be sure to install the Central Repository Index under Optional Components
      • (Try: add dependency, and then start typing "log", or "spring" and see what pops up)
    4. birt
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License