I just learned that Eclipse can automatically create (or suggest) variable names for you. The suggestions are based on the class of the object you're about to create, and any characters you've typed for the variable name so far.
For example, if I'm in a method and I type
Connection, followed by a space, then press the [Control][Space] keys, Eclipse adds a variable named
connection, so my line changes to
This feature gets even more interesting if you type one or two characters of the variable name, then press [Control][Space]. For example, if you type
StringBuffer s, then press [Control][Spacebar], Eclipse gives you a drop-down menu with choices of
sBuffer, which is pretty cool.
As I've described in other blog postings, this same [Control][Space] keystroke provides a number of suggestions in Eclipse, generally falling into a category named content assist. Whatever you call it, I like it, because it saves me a lot of time and keystrokes.
Unfortunately ctrl+space opens the spotlight search on my mac. I am wondering what's the key shortcut for autocompletion on mac?
It's been a while since I did this, but since I use ctrl+space to work in Eclipse on both of my Macs, I must have switched the Spotlight keystroke to command+space. You can do this by going into System Preferences, click the Spotlight icon, and then setting the "Spotlight menu keyboard shortcut" on the bottom of that panel.
You can also go into Eclipse and change the keystroke on that side to something else, but I prefer this approach, especially if you switch back and forth between Mac and Windows systems.
Hi Alvin, thanks for your reply! This is exactly what I found out after couple of minutes googling. I changed the hot key for spotlight to something else (dont remeber what exactly because I dont use it anyway) and replaced all short cuts in Eclipse to the windows-like settings. Your post put me on the right track though. Thanks a lot!
Cheers from Berlin, Germany
I'm glad to hear you found it.
Cheers (currently from Louisville, Kentucky)
I am a long time user of Eclipse and just started using it on a Mac. I had no idea why Ctrl-Space did not work like it did on Windows (aka Windoze) platforms. I happy to have found your tip here. Getting the Eclipse shortcuts back is such a time saver.