Eugene Marin
Eugene Marin

Reputation: 1796

Eclipse autocompletion problem

Just installed Eclipse Helios (Win7 64) and I'm having a strange problem. I type syso-Ctrl-Space which is expected to complete to System.out.println("") but it doesn't work! I searched the web for about an hour now, I set Preferences > Java > Editor > Content Assist to defaults, nothing. Everything else seems to work. Ideas?
To be clear: the shortcut works, it completes everything except "syso" as seen so far, on syso (also tried sysout) it says "No Default Proposals". I couldn't find this kind of shortcuts in the Content Assist, but I set them to default anyway.

Upvotes: 15

Views: 42555

Answers (12)

Ronald Wilson
Ronald Wilson

Reputation: 1

Go to Windows > Preferences > Java > Editor > Templates >

Scroll down to sysout in the Name column To change the shortcut to syso click on the name and change sysout to syso manually

Scroll down to sysout in Context column To make the shortcut active change the Context for sysout to Java.

Your welcome :)

Upvotes: 0

Binay Sharma
Binay Sharma

Reputation: 41

I am using Eclipse Galileo and had the same problem. Even after trying the above proposed solutions but it didn't work. After making the below change it finally comes out.

  1. Go to Windows->Preferences->Java->Editor->Templates
  2. Select sysout template and edit it.
  3. Change the context from Java statement to Java.

And it worked for me. I hope this will be helpful for you.

Upvotes: 4

You might have overlapping shortcuts.. Goto 'Overview' than the 'Keys' subsection. Type "ctrl +space" in the 'filter text' section. You should see the "content assist" and probably another command with the same shortcut. If another shortcut does exists, change its shortcut to something else.

Upvotes: 0

phil294
phil294

Reputation: 10822

DIRTY WORKAROUND: You can try out the following AutoHotkey-Code if you're still struggling like I am (STILL haven't been able to fix it myself)

#persistent
#ifwinactive ahk_class SWT_Window0  ; eclipse java
:*:syso::
sendraw System.out.println()`;
loop, 2
    send {left}
return
#ifwinactive

You need to write this in a .ahk file and run it (AutoHotkey needs to be installed). You might wanna put this file into your startup folder. It's a very useful tool, you might wanna expand it one day.

Upvotes: 0

Georgi
Georgi

Reputation: 251

Just found the solution for Eclipse Luna: write syso and press CTRL+Space and click on "enable intelligent code completion" and you are set. I am sure you can find it somewhere in the options as well but this way it is fast and easy!

Upvotes: 0

Mayank Nema
Mayank Nema

Reputation: 233

Just go to the below address:

Windows->Preferences->Java->Editor->Content Assist->Advanced

and click restore default..........that's all

its work like a charm again.

Upvotes: 1

cfh008
cfh008

Reputation: 456

You may try to set the shortcut of Content Assist with ALT+L, if it works, then you can choose your favorite shortcut again. (The shortcut Ctrl+Space conflicts with the shortcut of switching input method). In eclipse on linux, the shortcut of Word Completion is ALT+/, so if you set this as the shortcut of Content Assist it also conflicts.)

Upvotes: 1

Imran
Imran

Reputation: 1

Also check in this eclipse menu: Windows -> Preferences -> Java -> Appearance -> Type Filters

If you see java.* or javax.* here then try removing it (or Restore Default will do the job) and see that works, it did for me.

Upvotes: 0

mwengler
mwengler

Reputation: 2778

Your cursor needs to be located in a place where it would be legal to get that line. If your cursor is within a method definition and you type syso you will get the replacement. However if your cursor is in the portion of the text outside of any method definition, say where you declare variables for your class for instance, then syso will not suggest the illegal line system.output.println();.

I had this problem, read all the answers here, became convinced that it MUST be working in my copy, and realized I had been typing syso BELOW the closing } of my last method instead of in the method.

Eclipse on!

Upvotes: 1

PraveenMax
PraveenMax

Reputation: 717

If you still cant get auto-completion working,try enabling the Template proposals under Content assist menu.This is the exact location,

Windows->Preferences->Java->Editor->Content Assist->Advanced

And make sure you have only one entry for syso(Under Templates menu).

Upvotes: 17

Bill
Bill

Reputation: 2633

As Peter stated, it is under Window -> Java -> editor -> templates. Look for the line with the following values.

sysout "Java Statements" "Print to standard out" "on"

the preview should be as follows...

System.out.println(${word_selection}${});${cursor}

Upvotes: 3

Peter Perháč
Peter Perháč

Reputation: 20782

I believe the right template is "sysout" and I believe this can be configured somewhere but could not tell you where. Try sysout and then Ctrl+Space It's a template, you can find all templates under

Window -> Preferences -> Java -> Editor -> Templates

There you can see that the template name is "sysout" this will then trigger the string substitution for System.out.writeln() but you can change both the template name (if you prefer syso) and/or the actual code produced by invoking the template

Cheers

Upvotes: 9

Related Questions