my most commonly used features are
ctrl+1 quick-fix / spell-checker
- ctrl+shift+t load class file by classname
- ctrl+shift+r load any file by filename
matches are made on the start of the class/filename. start your search pattern with a * to search anywhere within the filename/classname.
- ctrl+shift+f format source file (set up your formatting style in window | preferences | java | code style | formatter)
- ctrl+shift+o organise imports
- alt+s,r to generate getters and setters
- alt+s,v to insert method signatures for overidden methods from superclass or interface
- alt+shift+l extract text-selection as local variable (really handy in that it determines and inserts the type for you.
- alt+shift+m extract text-selection as a method
- alt+shift+i inline selected method
running and debugging.
alt+shift+x is a really handy prefix to run stuff in your current file.
- alt+shift+x, t run unit tests in current file
- alt+shift+x, j run main in current file
- alt+shift+x, r run on server
there are more. the options are shown to you in the lower-right popup after hitting alt+shift+x.
alt+shift+x can be switched for alt+shift+d in all the above examples to run in the debugger.
as of the recent ganymede release, you can now switch of validation in specified files and folders. i've been waiting for this feature for ages.
- go to project | properties | validation
- click on the ... button in the settings column of the validator you want to shut up
- add a rule to the exclude group
- hold down ctrl to make all variables, methods and classnames hyperlinks to their definitions.
- alt+left to navigate back to where you clicked ctrl
- alt+right to go "forwards" again
i find the project-specific settings useful in eclipse 3.3.
for example, if you have several developers working on a project who have different code styles for curly braces, line spacing, number of imports etc. then you can specify the style settings for the project. then you can configure the save actions so that the code is automatically formatted when a file is saved. the result is everyone's code is formatted the same before it's checked in.
i use a lot of the above and also like for quick search: ctrl+j then type what i am looking for, then ctrl+k for next occurrence.
shift+alt+b for the simple navigation row over the editor.
i've just released this blog post about top 5 useful hidden eclipse features. it contains:
- favorites: types and members that will always show up in auto-completion
- the awesome block selection mode: for multi-line editing
- the egit staging view: much better than git itself
- type filters: to remove awt and
java.lang.objectstuff from auto-completion
- formatter tags: to delimit code sections that shouldn't be auto-formatted
alt+left and alt+ right will navigate you forward and back.
i am also a fan of eclipse, however since i spend a majority of my time in visual studio, i will suggest that you read eric sink's series of articles "c# to java" (parts 1-4). not only is eric always an entertaining read, but this brief series covers some awesome eclipse insight for those who have not been into eclipse or have been away from it for a while:
from c# to java: part 1
from c# to java: part 2
from c# to java: part 3
from c# to java: part 4
ctrl-shift-m while the cursor is on a class name in your java file, will specifically add that and only that class to your imports. this is different from ctrl-shift-o which will not only add those imports not already defined, but will also remove imports not currently needed, something you might not necessarily want to do.
i forgot about [ctrl+2 -> r] scope variable rename. place the cursor in the variable you wish to rename, press ctrl+2, then r, then type the new name watching all instances of that variable get renamed at the same time.
it's awesome at refactoring hungarian notation.
alt-shift-a is extremely useful in a few situations.
a lot of the key bindings depend on the perspective and view currently active.
my most used ones for the java perspective:
- ctrl-shift-r open resource
- ctrl-shift-t open type
- ctrl-1 quick fix/refactor
- ctrl-j incremental search
- ctrl-h search in files (select a base directory and set scope to selected resources)
- ctrl-o list methods
- ctrl-alt-h open call hierarchy
- ctrl-shift-l list shortcut keys
- hit ctrl-shift-l again to go directly to preferences to change key mappings
i'd like to add two additional shortcuts:
ctrl+f6 switch between open editors (ctrl+shift+f6 to scroll through the list in the opposite direction)
ctrl+f11 start program in debug mode
f11 start program in normal mode
ctrl+shift+x selected text becomes uppercase
ctrl+shift+y selected text becomes lowercase
one key feature: shift+alt+t for the refactoring menu.
- ctrl-shift-t, but only type the initial characters (and even a few more) of the class you're looking for. for example, you can type "netli" to find networklistener
- in the search window, ctrl-. takes you to the first leaf of a tree branch
- alt-/ is word completion. slightly different from ctrl-space
ctrl+shift+p to jump to the matching bracket/parenthesis.
it's a great feature. eclipse has its own mini-cvs for all files in a project. if you want to revert some change you made, or even restore deleted file - you can right click on the project and select "restore from local history".
just saved my ass *tears of joy*
eclipse auto refresh isn't on by default so if you make changes to a file outside of eclipse, the change won't be reflected in your build. this is very annoying if you just did an svn/git update/rebase and things aren't working the way they're supposed to.
turn it on in windows->preferences->workspace and tick refresh automatically.
ctrl+page down / ctrl+page up to switch between opened editors
ctrl+e to also switch between opened editors (allows to type the name)
ctrl+o is extremely important for me. you don't longer need the outline view then (you can close it which will give you more space). then, you can type a method name or just the beginning of it and you quickly can get to it. i also use it to inspect what stuff is available. for example: ctrl+o and then type get ... now i see all getters.
f3 while an element is selected in the code: brings you to its definition or it's source. e.g. used on a method call it brings you into the source code of that method.
ctrl+m to maximize the current window
as already said, ctrl+3 is extremely good. it basically allows you to use eclipse completely without a mouse. just type ctrl+3 and then package explorer for example.
ctrl+f8 cycle trough perspectives
ctrl+l allows to type a line number and brings you directly to that line.
ctrl+shift+g searches for all references to the selected element in the workspace.
and not a shortcut: in the project settings under java editor you can find save actions. this allows you to set up the project so that the code is automatically cleaned up and formatted when you save a file. that's very good it safes you from constantly pressing ctrl+o and ctrl+f.
ctrl-alt (up/down) copy selected line(s) above or below current line.
alt (up/down) move current (or multiple selected) lines up or down
ctrl-shift-r bring up the resource window, start typing to find class/resource
ctrl-o bring up all methods and fields for the current class. hitting it again will bring up all methods and fields for current class and super classes.
ctrl-/ or ctrl-alt-c comment single or multiple lines with //
ctrl-shift-/ comment selected lines with /* */
ctrl-. take you to the next error or warning line
in terms of actual features, rather than shortcuts, i strongly recommend taking a look at mylyn.
it essentially skins eclipse with a task focussed view. it tracks the files you touch when working on a task, and focusses many aspects of the ui onto the resources that it decides are relevant to the job in hand. eclipse can be somewhat busy to look at, especially with a big multi module project, and mylyn helps cut through the cruft. the connectivity to issue tracking software and source control repositories is also excellent.
in my experience, it polarises opinion amongst those who try working with it, which is probably a sign that it is offering something interesting... don't mean to sound like a fanboy - it is definitely worth a look though.
a shortcut that i use everyday is ctrl+k. in your editor (not only java file), simply select a text (like a variable, a function, etc.), and then use this shortcut to go to the next occurrence of this text in the current editor. it's faster than using the ctrl+f shortcut...
note also that you can use ctrl+shift+k to search backwards.
this is cool: if someone has emailed you a stack trace, you can copy and paste the stack trace into eclipse's console window. you can then click on class names in the stack trace as if your own code had generated it.
- Less known but useful features in Eclipse
- Seeking useful Eclipse Java code templates
- Hidden features of Eclipse
- Most useful shortcut in Eclipse CDT
- Eclipse plugins vs features vs dropins
- Useful Eclipse features?
- Eclipse vs. Visual Studio: What are the features in Eclipse that are not present in Visual Studio and vice versa?
- Building Eclipse plugins and features on the command line
- Trying to install new features in Eclipse (using ADT as the base package)
- is there Eclipse useful Add On for AutoComplete function like xCode?
- How do I build an Eclipse RCP app so that its features can be updated automatically?
- How to find list of installed Eclipse features from external program?
- Subclipse installed but no features appear in Eclipse 4.2 Juno
- Why does Eclipse let me compile some Java 7 language features into Java 6 class files?
- What are the new features in Eclipse Galileo?
- Cucumber features are not being recognized by Eclipse
- Install Eclipse without any Features
- Using Eclipse debugging features (breakpoints etc.) for Dropwizard server development
- Are features optional or not in an Eclipse e4 application/plugin?
- For java, which is more useful Eclipse OR Netbeans?
- Getting a list of installed features in an Eclipse RCP application
- Why can't I see new features in my Eclipse update site?
- How to enable Eclipse debugging features in a web application?
- Eclipse + Android SDK, won't fetch, update, connect, or do anything useful
- Eclipse marketplace can't confirm selected features to install
- Eclipse Mars integration with WAS Liberty server 22.214.171.124 does not recognize some Java EE 6 installed features
- How to install all features from a p2 update site to an Eclipse using the command line?
- How to reuse the Eclipse 4 IDE Perspective Features in an RCP Application
- How to activate features of EPIC Perl plugin for Eclipse
- New eclipse installation using old features and plugins
More Query from same tag
- My code failed to read arabic values from res/values-ar/strings.xml
- Android Fragment Content Lost
- invoking web services from eclipse
- How to Keep Highlighted ListView Item and Its Status in the Contextual Action Bar during Device Orientation Change
- Debug Eclipse from the moment plugin starts running
- lost the ability to view memory, etc via Eclipse CDT debug perspective
- wirless interface between pc and jn5148 using jennic stack
- How to set top-left corner icon of an eclipse 4 APP
- How do I add the option for "Project and External Dependencies" to my build path in Eclipse?
- Creating a coin calculation
- Eclipse: How to increase find/replace history?
- How to use eclipse-pmd rulesets configuration
- Should classes with same names in the same packages in different deployment units conflict in Java
- Eclipse using wrong build while debugging
- Java generics Eclipse compiler bug?
- difference between this and this@entry?
- No implementation of method: :as-file of protocol: #'clojure.java.io/Coercions found for class: clojure.lang.PersistentVector
- How can I find an Eclipse update site of a specific class/package
- Eclipse giving out an error while adding springframework dependency in maven .pom
- Using TelephonyManager in Android in a class that is NOT an activity
- Convert Java stream to regular for loop expression in Eclipse IDE
- How can I import all unimported classes in Scala IDE?
- Creating a new project in eclipse
- Eclipse CDT - using objdump in Windows
- Eclipse plugins
- Cannot get Microfocus Visual Cobol Personal Edition to install on Windows 7
- Eclipse For Android - Troubleshooting Android Virtual Device
- Database not open exception while inserting into sqlite database
- nullPointerException when trying to programmatically install a bundle in Equinox
- Get inflate ViewGroup of a layout with fragment