Eclipse autocompletion problem

2019-03-15 04:43发布

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.

11条回答
ゆ 、 Hurt°
2楼-- · 2019-03-15 05:16

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.

查看更多
唯我独甜
3楼-- · 2019-03-15 05:17

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

查看更多
Emotional °昔
4楼-- · 2019-03-15 05:20

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.

查看更多
冷血范
5楼-- · 2019-03-15 05:24

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.

查看更多
一夜七次
6楼-- · 2019-03-15 05:27

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.

查看更多
迷人小祖宗
7楼-- · 2019-03-15 05:29

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}
查看更多
登录 后发表回答