Thursday, October 18, 2007

Useful Eclipse key shortcuts

I've collected some useful Eclipse key shortcuts:

Key combinationEffect

Ctrl+Shift+CComment/Uncomment selection

Ctrl+Shift+/Comment selection

Ctrl+DDelete line

Ctrl+DelDelete next word

Ctrl+BkspDelete previous word

Ctrl+Shift+DelDelete till EOL

Alt+Shift+MExtract method

Ctrl+FFind and replace

Ctrl+KFind next

Ctrl+Shift+KFind previous

Ctrl+LGo to line

Ctrl+Shift+DGo to matching bracket

Ctrl+Shift+enterInsert line above

Ctrl+EnterInsert line below

Ctrl+Shift+FAuto format selected code

Enjoy :)

3 comments:

Dmitry said...

You might find annoying the fact, that some key combinations in Eclipse are not the ones you got used to, so
what you should do is - you'd go to Eclipse->Pref->General->Keys
and adjust all the key combinations the way you like, BUT each time you create NEW workspace
eclipse will loose all the key-settings and you will have to re-assign (and resolve possible conflicts and stuff) all
you key combination all over again! What a pain in the ass!!!

I chase down where Eclipse store your settings.. it is plain XML file, which you can copy from one workspace into another
to make magic happen and all your keys are in place! Everybody is happy!

1) [Adjust & Store]
As soon as you finish adjusting key in a way you like (doesn't matter for C++ view or for Ruby plugin), just find and store
somewhere this file:
.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs

note: if you didn't change prefs, this file doesn't exist on a fresh workspace.

2) [Transfer by coping]
In order to transfer your key settings to new eclipse-workspace just copy your stored file into this location of new workspace:
.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs

3) [Restart]
then don't forget to restart your Eclipse platform either by closing it and opening it again, or just by switching
to another workspace and then switching back

4) [Enjoy]
Don't forget to enjoy your life! ;)
Dmitry Shevkoplyas

Dmitry said...

hmm.. message got cut for some reason.. blog doesnt allow long lines here, so the full path to the magic file, once again, is:

.metadata/
.plugins/
org.eclipse.core.runtime/
.settings/
org.eclipse.ui.workbench.prefs

Woland said...

Thank you Dmitry!

It's quite a useful comment.