views:

528

answers:

11

I know there is a trick that when you type quickly code in Eclipse, you can hit some secret keys and it will auto-complete the missing parts. Who knows them?

example: I have someVeryLongVariablesWhichIWantToTypeFast and I start typing someVeryLongVa but nothing happens. Only when I type method names a yellow box appears that wants to help me.

+20  A: 

Ctrl + Space is the autocomplete shortcut

All shortcuts you can find under Window -> Preferences -> General -> Keys

Peter Smit
wow @ kbd tag. cool.
serg
how'd you insert this images?
HelloMoon
With the < kbd > < / kbd > tag (without spaces)
Peter Smit
+2  A: 

I kind of remember CTRL+SPACE was the shortcut for autocomplete.

slipbull
+1  A: 

General Eclipse tips

  • Get rid of all the crap that you'll never use
  • if you do web-dev ... install the database, php, pydev, modules and plugins
  • install svn/cvs/git plugin
  • use Trac
  • have different code enviornments for different code types, i.e. one for python-dev, c++, and so on.
  • wait a few weeks to months before updating
  • i have about 100 premade mini scripts that i use frequently.
  • learn to develop your own plugins, as it's easy and fun.
dassouki
That's great and all, but it doesn't really answer the question asked. not to mention it's pretty ambiguous. (What crap is he never going to use, and how does he get rid of it? What are some of your 100 frequently used scripts? etc...) Please stick to answering the question that was actually asked, and ensure that your answers are detailed enough that they can actually be followed to a solution.
Toji
+4  A: 

http://eclipse-tools.sourceforge.net/EclipseEmacsKeybindings_3_1.pdf

ufukgun
+1 i posted this link somewhere else.
Markus Lausberg
"Here's a nickel. But yourself a proper computer."
skaffman
+7  A: 

My favourites:

  • Ctrl + Space - auto complete
  • Ctrl + 1 - show quick fix options when you are over an error / warning
  • Shift + Ctrl + L - list short cuts
jjujuma
+2  A: 

"Ctrl + Shift + O" (the letter, not zero) : resolve all dependances automaticall. In Java, it's a life saver as it cleans old packages and add the required one without a single line to write.

"Right clic" then "refactor" : all the features are handy, but I espacially love "rename" (ctrl+shift+R, c.f comments) because it will apply the changes to all the project. No more tricky find / replace wit regexp to do ensure you breal nothing else :-)

"Right clic" then "source" : equally useful, with a special mention to "generate getter and setter" and "implement methods"

Ctrl + D : delete a line. Kinda cool.

e-satis
Rename = ctrl+shift+R also
MatrixFrog
+7  A: 
AntóinÓg
+1  A: 

For some applications, the answer is to generate the code using EMF. But the EMF learning curve is significant.

Stephen C
+4  A: 

One trick that I love in Eclipse for Java is writing backwards (meaning you write the client before the code it calls). We typically think of autocomplete to help us with methods and variables that already exist. This is okay, but even cooler is when a method/class does not exist.

Try typing this code into a method (anywhere, really):

Who who = new Who();
who.whatUpMan("hi", 32);

Now left-click on the Who at the beginning. It will give you the choice to create a class, interface, enum, etc.

Now left-click on the whatUpMan. It will prompt you to create the method with the right parameter types and everything.

These are called "Quick Fixes" in Eclipse and they give you total freedom to code from the client "backwards" to classes it utilizes. And when you've already got the method, of course, control-space and control-shift-space (to see parameters for methods) are your friends.

Yar
I adopt this approach for writing tests. It's an example of how having tests can make your apis a lot easier to use, because they are designed from the user in.
Dan Gravell
+2  A: 
Robert Munteanu
That's a crutch! I use the space bar like a real cowboy! Just kidding, +1 for mentioning this feature. I use it in Netbeans for Ruby, PHP, HTML and Java.
Yar
A: 

Some more time savers that don't seem to be mentioned:

  • Ctrl+3 'Quick Access' which basically let's you reach anything without clicking around too much. E.g. type 'nav' in the popup dialog, rather than Window | Show View | General | Navigator or wherever it is.

  • Ctrl+O 'Quick Outline': when editing Java (and some other things), pops up a lighweight dialog so that you find anything in the file by a few keystrokes

  • Shift+Alt+T 'Refactoring', and things below that menu - look for shortcuts there, use 'Rename', 'Move', 'Extract method', 'Change method signature' often

  • Alt+Up/Down move blocks of code up/down without cut/paste

  • Alt+Shift+Up/Down select various levels of code (expressions,statements, methods, class) easily

  • Ctrl+1 on the selected code offers you cool stuff eg. Extract to variable/constant/method; Split variable declaration -- see others above, or just try it on anything

  • Ctrl+Shift+R find any file in the workspace, similar to Ctrl+Shift+T to find types

inger