• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generate code templates in Eclipse by another shortcut!

 
Volodymyr Lysenko
Ranch Hand
Posts: 511
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Volodymyr Lysenko
Ranch Hand
Posts: 511
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic