Faster way (keyboard shortcuts?) to use quick fixes in Eclipse?
I often use the Eclipse feature (Galileo) of suggested error corrections to automatically create code stubs or to refactor things. For example, I would write a method that calls other methods which don't exist yet, then move the mouse over the error message and click on "create method". Or, change this
to the class name and choose "add static
modifier" from the quick fixes.
I think this is very convenient because it lets me stay in one place in my code and sort of "remotely" wire up what's not currently visible on my screen. What I think is annoying though, is that I have to leave the keyboard, hover my mouse over the error symbol, wait for the tooltip to pop up, and click on the option (doing that, I sometimes move the mouse a little over the edge and the tooltip goes away again - very annoying).
Am I missing a faster method here? I can't seem to find a keyboard shortcut, but then I have overlooked stuff from the huge preference dialog before.
Solution 1:
Ctrl+1 : Quick Fix.
(Cmd+1 on Mac)
Just put your cursor on the part you suspect you can perform an action (correction, refactoring, ...) and hit the Quick Fix
shortcut. The same popup will be displayed, and you can select the right option with the up and down keys.
That, combined with Ctrl+3 (Quick Access
) gives you most of eclipse features at your fingertips ;)
See also:
- Eclipse Tip: Shortcut to Quick Fix
- My Favorite Eclipse Shortcut: Quick Fix
- Eclipse hotkeys: eclipse shortcuts gold mine.
Solution 2:
As an additional tip, a specific type of quick fix I use all the time has a dedicated shortcut:
Alt+Shift+J: Add Javadoc comment stub for current method.
Solution 3:
After using ctrl+1 like mentioned in the top answer, press ctrl + enter to apply the selected fix all to problems of the same category.