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
  • Sign in to post comments.

Eclipse Foundation Blogs

  • Ian Skerrett (857 posts)
  • Wayne Beaton (796 posts)
  • Mike Milinkovich (290 posts)
  • Benjamin Cabé (131 posts)
  • Ivar Grimstad (104 posts)
  • Tanja Obradovic (39 posts)
  • Thabang Mashologu (32 posts)
  • Christopher Guindon (15 posts)
  • Roxanne Joncas (14 posts)
  • Paul Buck (11 posts)
  • Frédéric Desbiens (11 posts)
  • Brian King (9 posts)
  • Mikaël Barbero (9 posts)
  • Jameka Woodberry (9 posts)
  • Hudson Kelly (8 posts)
  • Denis Roy (5 posts)
  • Gabriela Motroc (4 posts)
  • Gael Blondelle (3 posts)
  • Shabnam Mayel (3 posts)
  • Shanda Giacomoni (1 posts)
  • Paul White (1 posts)
  • Jacob Harris (1 posts)
  • Stephanie Swart (1 posts)
  • Michael Plagge (1 posts)
  • Sharon Corbett (1 posts)

Recent blog posts

  • Eclipse Theia Blueprint Now Available for Download
  • Hashtag Jakarta EE #67
  • Three Good Reasons to Complete the Jakarta EE Developer Survey
  • Hashtag Jakarta EE #66
  • Why Java Developers Continue to Rely on Jakarta EE
  • Open VSX: A Vendor-Neutral Home for VS Code Extensions
  • Hashtag Jakarta EE #65
  • Introducing New Che Workspaces on OpenShift
  • Eclipse Jetty 11 Supports the Big Bang
  • Meet Adoptium: Open Source Java Runtimes for Enterprises
More

Eclipse Foundation

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

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