1
votes

Lets say I have a Class "Vehicle"

In netbeans, I can type:

Vehicle v = new Vehicle();

When i type "v.", I instantly get a list of all the class functions and fields

But in Eclipse, when I type "v." nothing pops up.

Can someone tell me how to enable this option in Eclipse? Also how can I format my code in eclipse?

Edit: When i Press CTRL+Space, after typing "v.", i get a small window that says "No default Proposals"

5
Highlight code and press Crtl + i to formatokin33
See this answer to configure the Auto Complete to be "instant" stackoverflow.com/a/4225995/843318Jonathan Spooner
When you type what you typed (Vehicle v and so on), nothing should show up because object v is not created yet. The only 2 things you can do is assign a value (for example by calling new Vehicle() like you did), or finish the statement with a semi-colon.Daniel Gabriel
@JonathanSpooner thanks!Shehryar Farooq

5 Answers

2
votes

Try pressing Ctrl-space.

Here is a list of shortcuts. In Eclipse, I believe that Ctrl-Shift-L shows many more.

2
votes

The default keyboard shortcut to format code is Ctrl-Shift-F.

For preferences regarding content assist, look at Window - Preferences - Java - Editor - Content assist. The popup may appear automatically, or may appear by typing Ctrl - space. You probably don't see anything appearing because the code isn't valid. Make sure to import the Vehicle class (Ctrl - Shift - O).

1
votes

Hit ctrl + space to get autocompletion

0
votes

The default option you have on eclipse is CTRL+SPACE . You can alter the short cut by Go to preferences >General > editor >Keys . There in the left panel you can set whatever shortcut you like . I prefer mostly the default one .