This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes IDEs, Version Control and other tools and the fly likes Generate code templates in Eclipse by another shortcut! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Generate code templates in Eclipse by another shortcut!" Watch "Generate code templates in Eclipse by another shortcut!" New topic
Author

Generate code templates in Eclipse by another shortcut!

Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

Hello!

When I was on Netbeans I could extremely easily generate template: pressing 'Ob' + TAB I received 'Object', or 'St'+TAB produces 'String'.

In eclipse I created my own template that generates 'Object' by typing 'Ob'.
After I type 'Ob' I need to press CTRL+SPACE to call that template and eclipse instead of generating 'Object'
gives me huge list of all classes that start with 'Ob'. It is not convenient at all.

Does anybody know what to do in eclipse to have code template generation by pressing TAB instead of CTRL+SPACE?

Thank you!


True person is moral, false is right!
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Here is the list of proposal that will show up for CTRL-Space: Windows | Preferences | Java | Editor | Content Assist | Advanced
You could uncheck everything except Template Proposals in the top listing box.
Note also the bottom listing - this is the order in which proposals show up of you hit CTRL-Space repeatedly - by default the Template Proposals show up on top the second time you hit CTRL-Space.


JBoss In Action
Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

Hello!

Thanks for reply!

Indeed when I hit ctrl+space twice I see my own template proposals. However I found a way to show up list of template proposals by pressing key binding.
  1. Go to Windows - Preferences - Java - Editor - Content Assist - Advanced. There you will see sentence under first table:
    Individual key bindings can be assigned to each proposal kind on the 'Keys' prefernces page
    .

  2. Click Keys word and type 'template proposal' in filter box.

  3. Select Content Assist (Template Proposals) and assign key binding Shift+Tab(but not Tab) by clicking on button with right arrow. Press Apply and then OK button.

  4. Type 'try' and press Shift+Tab. You will see list with single proposal to build try catch block. Hovewer my own code templates are generated automatically by pressing Shift+Tab without any popup lists!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generate code templates in Eclipse by another shortcut!