Skip to main content
  • Log in
  • Manage Cookies
Eclipse Foundation
Download
  • Projects
  • Working Groups
  • Members
  • Community
    • Marketplace
    • Events
    • Planet Eclipse
    • Newsletter
    • Videos
    • Blogs
  • Participate
    • Report a Bug
    • Forums
    • Mailing Lists
    • Wiki
    • IRC
    • Research
  • Eclipse IDE
    • Download
    • Learn More
    • Documentation
    • Getting Started / Support
    • How to Contribute
    • IDE and Tools
    • Newcomer Forum
  • More
      • Community

      • Marketplace
      • Events
      • Planet Eclipse
      • Newsletter
      • Videos
      • Blogs
      • Participate

      • Report a Bug
      • Forums
      • Mailing Lists
      • Wiki
      • IRC
      • Research
      • Eclipse IDE

      • Download
      • Learn More
      • Documentation
      • Getting Started / Support
      • How to Contribute
      • IDE and Tools
      • Newcomer Forum
  1. Home
  2. Blogs
  3. Wayne Beaton's blog
  4. Code Template Expansion in Eclipse

Code Template Expansion in Eclipse

Monday, February 27, 2006 - 19:23 by Wayne Beaton

Eclipse is great for lazy folks like me. By typing just a few keystrokes and hitting “ctrl-space”, Eclipse will generate a lot of code for you. For example, if you open a Java editor, move your cursor to a blank line and type “sysout”, it will expand what you’ve typed into System.out.println() and conveniently put the cursor between the parentheses.

I tend to use “toarray” a lot. This one is handy for converting a collection type into an array; it changes “toarray” into (type[]) collection.toArray(new type[collection.size()]). Even better, it put focus over the replaceable bits in the template and lets you tab through them. At first, it will put focus on “type”; anything you type there will appear in both places the word “type” appears. When you hit tab, it will move focus to “collection”. Very handy when you’re up against Java weirdness (you have to admit that the mechanism for converting a collection into an array is just weird looking).

There are a lot more templates. You can see the list that applies to the Java editors in the preferences dialog (Java > Editor > Templates).


Go ahead. Be lazy. You’re in good company.

Tags: 
Uncategorized
Source: 
https://waynebeaton.wordpress.com/2006/02/27/code-template-expansion-in-eclipse/
  • Wayne Beaton's blog

Eclipse Foundation Blogs

  • Wayne Beaton (818 posts)
  • Mike Milinkovich (314 posts)
  • Ivar Grimstad (197 posts)
  • Benjamin Cabé (131 posts)
  • Tanja Obradovic (54 posts)
  • Thabang Mashologu (37 posts)
  • Paul Buck (19 posts)
  • Frédéric Desbiens (19 posts)
  • Brian King (19 posts)
  • Christopher Guindon (15 posts)
  • Gael Blondelle (14 posts)
  • John Kellerman (13 posts)
  • Hailley Seed (10 posts)
  • Denis Roy (9 posts)
  • Mikaël Barbero (9 posts)
  • Hudson Kelly (8 posts)
  • Michael Plagge (4 posts)
  • Shabnam Mayel (3 posts)
  • Shanda Giacomoni (3 posts)
  • Jacob Harris (2 posts)
  • Sharon Corbett (1 posts)
  • Paul White (1 posts)
  • Stephanie Swart (1 posts)
  • Clark Roundy (1 posts)

Recent blog posts

  • Hashtag Jakarta EE #136
  • Hashtag Jakarta EE #135
  • Eclipse Cloud DevTools Contributor Award: TypeFox for OpenVSX
  • Hashtag Jakarta EE #134
  • JBCNConf 2022
  • EclipseCon 2022 Registration is open
  • Hashtag Jakarta EE #133
  • Eclipse Cloud DevTools Digest - June, 2022
  • Hashtag Jakarta EE #132
  • Developer Week ’22
More

Eclipse Foundation

  • About Us
  • Contact Us
  • Sponsor
  • Members
  • Governance
  • Code of Conduct
  • Logo and Artwork
  • Board of Directors
  • Careers

Legal

  • Privacy Policy
  • Terms of Use
  • Copyright Agent
  • Eclipse Public License
  • Legal Resources

Useful Links

  • Report a Bug
  • Documentation
  • How to Contribute
  • Mailing Lists
  • Forums
  • Marketplace

Other

  • IDE and Tools
  • Projects
  • Working Groups
  • Research@Eclipse
  • Report a Vulnerability
  • Service Status

Copyright © Eclipse Foundation. All Rights Reserved.

Back to the top